Skip to content

Commit

Permalink
Auto merge of #75514 - gdhuper:gdhuper/replace_log_with_tracing, r=da…
Browse files Browse the repository at this point in the history
…vidtwco

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
  • Loading branch information
bors committed Aug 15, 2020
2 parents 3f32505 + d2753f9 commit 9b88e0a
Show file tree
Hide file tree
Showing 96 changed files with 109 additions and 104 deletions.
2 changes: 1 addition & 1 deletion src/librustc_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ doctest = false

[dependencies]
rustc_serialize = { path = "../librustc_serialize" }
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
rustc_span = { path = "../librustc_span" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_index = { path = "../librustc_index" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use rustc_lexer::unescape::{unescape_byte_literal, unescape_literal, Mode};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;

use log::debug;
use std::ascii;
use tracing::debug;

pub enum LitError {
NotLiteral,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["dylib"]
[dependencies]
lazy_static = "1.0"
libc = "0.2"
log = { package = "tracing", version = "0.1.18", features = ["release_max_level_info"] }
tracing = { version = "0.1.18", features = ["release_max_level_info"] }
tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
rustc_middle = { path = "../librustc_middle" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#![recursion_limit = "256"]

#[macro_use]
extern crate log;
extern crate tracing;
#[macro_use]
extern crate lazy_static;

Expand Down Expand Up @@ -1224,13 +1224,13 @@ pub fn install_ice_hook() {
}

/// This allows tools to enable rust logging without having to magically match rustc's
/// log crate version.
/// tracing crate version.
pub fn init_rustc_env_logger() {
init_env_logger("RUSTC_LOG")
}

/// This allows tools to enable rust logging without having to magically match rustc's
/// log crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose an env var
/// other than `RUSTC_LOG`.
pub fn init_env_logger(env: &str) {
// Don't register a dispatcher if there's no filter to print anything
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ path = "lib.rs"
doctest = false

[dependencies]
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
rustc_serialize = { path = "../librustc_serialize" }
rustc_span = { path = "../librustc_span" }
rustc_macros = { path = "../librustc_macros" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/diagnostic_builder.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{Applicability, Handler, Level, StashKey};
use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString};

use log::debug;
use rustc_span::{MultiSpan, Span};
use std::fmt::{self, Debug};
use std::ops::{Deref, DerefMut};
use std::thread::panicking;
use tracing::debug;

/// Used for emitting structured error messages and other diagnostic information.
///
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::{
pluralize, CodeSuggestion, Diagnostic, DiagnosticId, Level, SubDiagnostic, SuggestionStyle,
};

use log::*;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
use rustc_span::hygiene::{ExpnKind, MacroKind};
Expand All @@ -30,6 +29,7 @@ use std::iter;
use std::path::Path;
use termcolor::{Ansi, BufferWriter, ColorChoice, ColorSpec, StandardStream};
use termcolor::{Buffer, Color, WriteColor};
use tracing::*;

/// Default column width, used in tests and when terminal dimensions cannot be determined.
const DEFAULT_COLUMN_WIDTH: usize = 140;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern crate rustc_macros;

pub use emitter::ColorConfig;

use log::debug;
use tracing::debug;
use Level::*;

use emitter::{is_case_difference, Emitter, EmitterWriter};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_expand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doctest = false

[dependencies]
rustc_serialize = { path = "../librustc_serialize" }
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
rustc_span = { path = "../librustc_span" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_ast_passes = { path = "../librustc_ast_passes" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_expand/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{kw, sym, Ident, MacroRulesNormalizedIdent};
use rustc_span::Span;

use log::debug;
use std::borrow::Cow;
use std::collections::hash_map::Entry;
use std::{mem, slice};
use tracing::debug;

crate struct ParserAnyMacro<'a> {
parser: Parser<'a>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ rustc_span = { path = "../librustc_span" }
rustc_serialize = { path = "../librustc_serialize" }
rustc_ast = { path = "../librustc_ast" }
lazy_static = "1"
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
2 changes: 1 addition & 1 deletion src/librustc_hir/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use rustc_index::vec::IndexVec;
use rustc_span::hygiene::ExpnId;
use rustc_span::symbol::{sym, Symbol};

use log::debug;
use std::fmt::Write;
use std::hash::Hash;
use tracing::debug;

/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
/// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey`
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ doctest = false

[dependencies]
rustc_graphviz = { path = "../librustc_graphviz" }
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
rand = "0.7"
rustc_middle = { path = "../librustc_middle" }
rustc_data_structures = { path = "../librustc_data_structures" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#[macro_use]
extern crate rustc_middle;
#[macro_use]
extern crate log;
extern crate tracing;

mod assert_dep_graph;
pub mod assert_module_sources;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ doctest = false

[dependencies]
rustc_graphviz = { path = "../librustc_graphviz" }
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
rustc_middle = { path = "../librustc_middle" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern crate rustc_macros;
#[macro_use]
extern crate rustc_data_structures;
#[macro_use]
extern crate log;
extern crate tracing;
#[macro_use]
extern crate rustc_middle;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ doctest = false

[dependencies]
libc = "0.2"
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
rayon = { version = "0.3.0", package = "rustc-rayon" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc_ast = { path = "../librustc_ast" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_interface/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R
}

pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
log::trace!("run_compiler");
tracing::trace!("run_compiler");
let stderr = config.stderr.take();
util::setup_callbacks_and_run_in_thread_pool_with_globals(
config.opts.edition,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::interface::{Compiler, Result};
use crate::proc_macro_decls;
use crate::util;

use log::{info, warn};
use once_cell::sync::Lazy;
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::{self, ast, visit};
Expand Down Expand Up @@ -39,6 +38,7 @@ use rustc_span::symbol::Symbol;
use rustc_span::{FileName, RealFileName};
use rustc_trait_selection::traits;
use rustc_typeck as typeck;
use tracing::{info, warn};

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_interface/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<'tcx> Queries<'tcx> {
pub fn expansion(
&self,
) -> Result<&Query<(ast::Crate, Steal<Rc<RefCell<BoxedResolver>>>, Lrc<LintStore>)>> {
log::trace!("expansion");
tracing::trace!("expansion");
self.expansion.compute(|| {
let crate_name = self.crate_name()?.peek().clone();
let (krate, lint_store) = self.register_plugins()?.take();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_interface/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use log::info;
use rustc_ast::ast::{AttrVec, BlockCheckMode};
use rustc_ast::mut_visit::{visit_clobber, MutVisitor, *};
use rustc_ast::ptr::P;
Expand Down Expand Up @@ -33,6 +32,7 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, Once};
#[cfg(not(parallel_compiler))]
use std::{panic, thread};
use tracing::info;

/// Adds `target_feature = "..."` cfgs for a variety of platform
/// specific features (SSE, NEON etc.).
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "rustc_lint"
path = "lib.rs"

[dependencies]
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
unicode-security = "0.0.5"
rustc_middle = { path = "../librustc_middle" }
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ use rustc_trait_selection::traits::misc::can_type_implement_copy;

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

use log::{debug, trace};
use std::fmt::Write;
use tracing::{debug, trace};

// hardwired lints from librustc_middle
pub use rustc_session::lint::builtin::*;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use rustc_session::Session;
use rustc_span::symbol::Ident;
use rustc_span::Span;

use log::debug;
use std::slice;
use tracing::debug;

macro_rules! run_early_pass { ($cx:expr, $f:ident, $($args:expr),*) => ({
$cx.pass.$f(&$cx.context, $($args),*);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ use rustc_session::lint::LintPass;
use rustc_span::symbol::Symbol;
use rustc_span::Span;

use log::debug;
use std::any::Any;
use std::cell::Cell;
use std::slice;
use tracing::debug;

/// Extract the `LintStore` from the query context.
/// This function exists because we've erased `LintStore` as `dyn Any` in the context.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use rustc_target::abi::Abi;
use rustc_target::abi::{Integer, LayoutOf, TagEncoding, VariantIdx, Variants};
use rustc_target::spec::abi::Abi as SpecAbi;

use log::debug;
use std::cmp;
use tracing::debug;

declare_lint! {
UNUSED_COMPARISONS,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use rustc_span::symbol::Symbol;
use rustc_span::symbol::{kw, sym};
use rustc_span::{BytePos, Span, DUMMY_SP};

use log::debug;
use tracing::debug;

declare_lint! {
pub UNUSED_MUST_USE,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doctest = false
[dependencies]
flate2 = "1.0"
libc = "0.2"
log = { package = "tracing", version = "0.1" }
tracing = "0.1"
memmap = "0.7"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc_middle = { path = "../librustc_middle" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use rustc_span::symbol::{sym, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_target::spec::{PanicStrategy, TargetTriple};

use log::{debug, info};
use proc_macro::bridge::client::ProcMacro;
use std::path::Path;
use std::{cmp, env, fs};
use tracing::{debug, info};

#[derive(Clone)]
pub struct CStore {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_metadata/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
let name = tcx.crate_name(cnum);
let src = tcx.used_crate_source(cnum);
if src.dylib.is_some() {
log::info!("adding dylib: {}", name);
tracing::info!("adding dylib: {}", name);
add_library(tcx, cnum, RequireDynamic, &mut formats);
let deps = tcx.dylib_dependency_formats(cnum);
for &(depnum, style) in deps.iter() {
log::info!("adding {:?}: {}", style, tcx.crate_name(depnum));
tracing::info!("adding {:?}: {}", style, tcx.crate_name(depnum));
add_library(tcx, depnum, style, &mut formats);
}
}
Expand Down Expand Up @@ -191,7 +191,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
&& tcx.dep_kind(cnum) == CrateDepKind::Explicit
{
assert!(src.rlib.is_some() || src.rmeta.is_some());
log::info!("adding staticlib: {}", tcx.crate_name(cnum));
tracing::info!("adding staticlib: {}", tcx.crate_name(cnum));
add_library(tcx, cnum, RequireStatic, &mut formats);
ret[cnum.as_usize() - 1] = Linkage::Static;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ use rustc_span::Span;
use rustc_target::spec::{Target, TargetTriple};

use flate2::read::DeflateDecoder;
use log::{debug, info, warn};
use std::io::{Read, Result as IoResult, Write};
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::{cmp, fmt, fs};
use tracing::{debug, info, warn};

#[derive(Clone)]
crate struct CrateLocator<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{self, hygiene::MacroKind, BytePos, ExpnId, Pos, Span, SyntaxContext, DUMMY_SP};

use log::debug;
use proc_macro::bridge::client::ProcMacro;
use std::cell::Cell;
use std::io;
use std::mem;
use std::num::NonZeroUsize;
use std::path::Path;
use tracing::debug;

pub use cstore_impl::{provide, provide_extern};
use rustc_span::hygiene::HygieneDecodeContext;
Expand Down
Loading

0 comments on commit 9b88e0a

Please sign in to comment.