mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
switch log
crate to tracing
This commit is contained in:
parent
d15f646ff1
commit
ba0947dded
48 changed files with 277 additions and 239 deletions
|
@ -283,7 +283,7 @@ impl CargoWorkspace {
|
|||
let meta = from_value::<PackageMetadata>(metadata.clone()).unwrap_or_default();
|
||||
let is_member = ws_members.contains(id);
|
||||
let edition = edition.parse::<Edition>().unwrap_or_else(|err| {
|
||||
log::error!("Failed to parse edition {}", err);
|
||||
tracing::error!("Failed to parse edition {}", err);
|
||||
Edition::CURRENT
|
||||
});
|
||||
|
||||
|
@ -322,7 +322,7 @@ impl CargoWorkspace {
|
|||
// https://github.com/rust-lang/cargo/issues/7841
|
||||
// is fixed and hits stable (around 1.43-is probably?).
|
||||
None => {
|
||||
log::error!("Node id do not match in cargo metadata, ignoring {}", node.id);
|
||||
tracing::error!("Node id do not match in cargo metadata, ignoring {}", node.id);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
@ -335,7 +335,7 @@ impl CargoWorkspace {
|
|||
let pkg = match pkg_by_id.get(&dep_node.pkg) {
|
||||
Some(&pkg) => pkg,
|
||||
None => {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Dep node id do not match in cargo metadata, ignoring {}",
|
||||
dep_node.pkg
|
||||
);
|
||||
|
@ -385,7 +385,7 @@ impl CargoWorkspace {
|
|||
fn rustc_discover_host_triple(cargo_toml: &ManifestPath) -> Option<String> {
|
||||
let mut rustc = Command::new(toolchain::rustc());
|
||||
rustc.current_dir(cargo_toml.parent()).arg("-vV");
|
||||
log::debug!("Discovering host platform by {:?}", rustc);
|
||||
tracing::debug!("Discovering host platform by {:?}", rustc);
|
||||
match utf8_stdout(rustc) {
|
||||
Ok(stdout) => {
|
||||
let field = "host: ";
|
||||
|
@ -394,12 +394,12 @@ fn rustc_discover_host_triple(cargo_toml: &ManifestPath) -> Option<String> {
|
|||
Some(target.to_string())
|
||||
} else {
|
||||
// If we fail to resolve the host platform, it's not the end of the world.
|
||||
log::info!("rustc -vV did not report host platform, got:\n{}", stdout);
|
||||
tracing::info!("rustc -vV did not report host platform, got:\n{}", stdout);
|
||||
None
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Failed to discover host platform: {}", e);
|
||||
tracing::warn!("Failed to discover host platform: {}", e);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ fn cargo_config_build_target(cargo_toml: &ManifestPath) -> Option<String> {
|
|||
.args(&["-Z", "unstable-options", "config", "get", "build.target"])
|
||||
.env("RUSTC_BOOTSTRAP", "1");
|
||||
// if successful we receive `build.target = "target-triple"`
|
||||
log::debug!("Discovering cargo config target by {:?}", cargo_config);
|
||||
tracing::debug!("Discovering cargo config target by {:?}", cargo_config);
|
||||
match utf8_stdout(cargo_config) {
|
||||
Ok(stdout) => stdout
|
||||
.strip_prefix("build.target = \"")
|
||||
|
|
|
@ -20,7 +20,7 @@ pub(crate) fn get(cargo_toml: Option<&ManifestPath>, target: Option<&str>) -> Ve
|
|||
|
||||
match get_rust_cfgs(cargo_toml, target) {
|
||||
Ok(rustc_cfgs) => res.extend(rustc_cfgs.lines().map(|it| it.parse().unwrap())),
|
||||
Err(e) => log::error!("failed to get rustc cfgs: {:#}", e),
|
||||
Err(e) => tracing::error!("failed to get rustc cfgs: {:#}", e),
|
||||
}
|
||||
|
||||
res
|
||||
|
|
|
@ -54,7 +54,7 @@ impl Sysroot {
|
|||
}
|
||||
|
||||
pub fn discover(dir: &AbsPath) -> Result<Sysroot> {
|
||||
log::debug!("Discovering sysroot for {}", dir.display());
|
||||
tracing::debug!("Discovering sysroot for {}", dir.display());
|
||||
let sysroot_dir = discover_sysroot_dir(dir)?;
|
||||
let sysroot_src_dir = discover_sysroot_src_dir(&sysroot_dir, dir)?;
|
||||
let res = Sysroot::load(sysroot_src_dir)?;
|
||||
|
@ -62,7 +62,7 @@ impl Sysroot {
|
|||
}
|
||||
|
||||
pub fn discover_rustc(cargo_toml: &ManifestPath) -> Option<ManifestPath> {
|
||||
log::debug!("Discovering rustc source for {}", cargo_toml.display());
|
||||
tracing::debug!("Discovering rustc source for {}", cargo_toml.display());
|
||||
let current_dir = cargo_toml.parent();
|
||||
discover_sysroot_dir(current_dir).ok().and_then(|sysroot_dir| get_rustc_src(&sysroot_dir))
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ impl Sysroot {
|
|||
fn discover_sysroot_dir(current_dir: &AbsPath) -> Result<AbsPathBuf> {
|
||||
let mut rustc = Command::new(toolchain::rustc());
|
||||
rustc.current_dir(current_dir).args(&["--print", "sysroot"]);
|
||||
log::debug!("Discovering sysroot by {:?}", rustc);
|
||||
tracing::debug!("Discovering sysroot by {:?}", rustc);
|
||||
let stdout = utf8_stdout(rustc)?;
|
||||
Ok(AbsPathBuf::assert(PathBuf::from(stdout)))
|
||||
}
|
||||
|
@ -146,10 +146,10 @@ fn discover_sysroot_src_dir(
|
|||
.map_err(|path| format_err!("RUST_SRC_PATH must be absolute: {}", path.display()))?;
|
||||
let core = path.join("core");
|
||||
if fs::metadata(&core).is_ok() {
|
||||
log::debug!("Discovered sysroot by RUST_SRC_PATH: {}", path.display());
|
||||
tracing::debug!("Discovered sysroot by RUST_SRC_PATH: {}", path.display());
|
||||
return Ok(path);
|
||||
}
|
||||
log::debug!("RUST_SRC_PATH is set, but is invalid (no core: {:?}), ignoring", core);
|
||||
tracing::debug!("RUST_SRC_PATH is set, but is invalid (no core: {:?}), ignoring", core);
|
||||
}
|
||||
|
||||
get_rust_src(sysroot_path)
|
||||
|
@ -174,7 +174,7 @@ try installing the Rust source the same way you installed rustc",
|
|||
fn get_rustc_src(sysroot_path: &AbsPath) -> Option<ManifestPath> {
|
||||
let rustc_src = sysroot_path.join("lib/rustlib/rustc-src/rust/compiler/rustc/Cargo.toml");
|
||||
let rustc_src = ManifestPath::try_from(rustc_src).ok()?;
|
||||
log::debug!("Checking for rustc source code: {}", rustc_src.display());
|
||||
tracing::debug!("Checking for rustc source code: {}", rustc_src.display());
|
||||
if fs::metadata(&rustc_src).is_ok() {
|
||||
Some(rustc_src)
|
||||
} else {
|
||||
|
@ -185,7 +185,10 @@ fn get_rustc_src(sysroot_path: &AbsPath) -> Option<ManifestPath> {
|
|||
fn get_rust_src(sysroot_path: &AbsPath) -> Option<AbsPathBuf> {
|
||||
// Try the new path first since the old one still exists.
|
||||
let rust_src = sysroot_path.join("lib/rustlib/src/rust");
|
||||
log::debug!("Checking sysroot (looking for `library` and `src` dirs): {}", rust_src.display());
|
||||
tracing::debug!(
|
||||
"Checking sysroot (looking for `library` and `src` dirs): {}",
|
||||
rust_src.display()
|
||||
);
|
||||
["library", "src"].iter().map(|it| rust_src.join(it)).find(|it| fs::metadata(it).is_ok())
|
||||
}
|
||||
|
||||
|
|
|
@ -384,9 +384,9 @@ impl ProjectWorkspace {
|
|||
}
|
||||
};
|
||||
if crate_graph.patch_cfg_if() {
|
||||
log::debug!("Patched std to depend on cfg-if")
|
||||
tracing::debug!("Patched std to depend on cfg-if")
|
||||
} else {
|
||||
log::debug!("Did not patch std to depend on cfg-if")
|
||||
tracing::debug!("Did not patch std to depend on cfg-if")
|
||||
}
|
||||
crate_graph
|
||||
}
|
||||
|
@ -623,7 +623,7 @@ fn detached_files_to_crate_graph(
|
|||
let file_id = match load(detached_file) {
|
||||
Some(file_id) => file_id,
|
||||
None => {
|
||||
log::error!("Failed to load detached file {:?}", detached_file);
|
||||
tracing::error!("Failed to load detached file {:?}", detached_file);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
@ -847,7 +847,7 @@ fn sysroot_to_crate_graph(
|
|||
|
||||
fn add_dep(graph: &mut CrateGraph, from: CrateId, name: CrateName, to: CrateId) {
|
||||
if let Err(err) = graph.add_dep(from, name, to) {
|
||||
log::error!("{}", err)
|
||||
tracing::error!("{}", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue