mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
cargo fmt
This commit is contained in:
parent
87f837cec7
commit
7535bb4661
571 changed files with 2210 additions and 2458 deletions
|
|
@ -9,7 +9,7 @@
|
|||
use std::{cell::RefCell, io, mem, process::Command};
|
||||
|
||||
use base_db::Env;
|
||||
use cargo_metadata::{camino::Utf8Path, Message};
|
||||
use cargo_metadata::{Message, camino::Utf8Path};
|
||||
use cfg::CfgAtom;
|
||||
use itertools::Itertools;
|
||||
use la_arena::ArenaMap;
|
||||
|
|
@ -19,8 +19,8 @@ use serde::Deserialize as _;
|
|||
use toolchain::Tool;
|
||||
|
||||
use crate::{
|
||||
utf8_stdout, CargoConfig, CargoFeatures, CargoWorkspace, InvocationStrategy, ManifestPath,
|
||||
Package, Sysroot, TargetKind,
|
||||
CargoConfig, CargoFeatures, CargoWorkspace, InvocationStrategy, ManifestPath, Package, Sysroot,
|
||||
TargetKind, utf8_stdout,
|
||||
};
|
||||
|
||||
/// Output of the build script and proc-macro building steps for a workspace.
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ impl CargoWorkspace {
|
|||
// this pkg is inside this cargo workspace, fallback to workspace root
|
||||
if found {
|
||||
return Some(vec![
|
||||
ManifestPath::try_from(self.workspace_root().join("Cargo.toml")).ok()?
|
||||
ManifestPath::try_from(self.workspace_root().join("Cargo.toml")).ok()?,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use paths::Utf8Path;
|
|||
use rustc_hash::FxHashMap;
|
||||
use toolchain::Tool;
|
||||
|
||||
use crate::{utf8_stdout, ManifestPath, PackageData, Sysroot, TargetKind};
|
||||
use crate::{ManifestPath, PackageData, Sysroot, TargetKind, utf8_stdout};
|
||||
|
||||
/// Recreates the compile-time environment variables that Cargo sets.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@ mod tests;
|
|||
|
||||
use std::{
|
||||
fmt,
|
||||
fs::{self, read_dir, ReadDir},
|
||||
fs::{self, ReadDir, read_dir},
|
||||
io,
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use anyhow::{bail, format_err, Context};
|
||||
use anyhow::{Context, bail, format_err};
|
||||
use paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
|
|
@ -102,7 +102,9 @@ impl ProjectManifest {
|
|||
if path.extension().unwrap_or_default() == "rs" {
|
||||
return Ok(ProjectManifest::CargoScript(path));
|
||||
}
|
||||
bail!("project root must point to a Cargo.toml, rust-project.json or <script>.rs file: {path}");
|
||||
bail!(
|
||||
"project root must point to a Cargo.toml, rust-project.json or <script>.rs file: {path}"
|
||||
);
|
||||
}
|
||||
|
||||
pub fn discover_single(path: &AbsPath) -> anyhow::Result<ProjectManifest> {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,7 @@ impl TryFrom<AbsPathBuf> for ManifestPath {
|
|||
type Error = AbsPathBuf;
|
||||
|
||||
fn try_from(file: AbsPathBuf) -> Result<Self, Self::Error> {
|
||||
if file.parent().is_none() {
|
||||
Err(file)
|
||||
} else {
|
||||
Ok(ManifestPath { file })
|
||||
}
|
||||
if file.parent().is_none() { Err(file) } else { Ok(ManifestPath { file }) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ use base_db::{CrateDisplayName, CrateName};
|
|||
use cfg::CfgAtom;
|
||||
use paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use serde::{de, Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de};
|
||||
use span::Edition;
|
||||
|
||||
use crate::{ManifestPath, TargetKind};
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@
|
|||
|
||||
use std::{env, fs, ops::Not, path::Path, process::Command};
|
||||
|
||||
use anyhow::{format_err, Result};
|
||||
use anyhow::{Result, format_err};
|
||||
use itertools::Itertools;
|
||||
use paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
|
||||
use rustc_hash::FxHashMap;
|
||||
use stdx::format_to;
|
||||
use toolchain::{probe_for_binary, Tool};
|
||||
use toolchain::{Tool, probe_for_binary};
|
||||
|
||||
use crate::{
|
||||
cargo_workspace::CargoMetadataConfig, utf8_stdout, CargoWorkspace, ManifestPath, ProjectJson,
|
||||
RustSourceWorkspaceConfig,
|
||||
CargoWorkspace, ManifestPath, ProjectJson, RustSourceWorkspaceConfig,
|
||||
cargo_workspace::CargoMetadataConfig, utf8_stdout,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
@ -424,21 +424,13 @@ 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()?;
|
||||
tracing::debug!("checking for rustc source code: {rustc_src}");
|
||||
if fs::metadata(&rustc_src).is_ok() {
|
||||
Some(rustc_src)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if fs::metadata(&rustc_src).is_ok() { Some(rustc_src) } else { None }
|
||||
}
|
||||
|
||||
fn get_rust_lib_src(sysroot_path: &AbsPath) -> Option<AbsPathBuf> {
|
||||
let rust_lib_src = sysroot_path.join("lib/rustlib/src/rust/library");
|
||||
tracing::debug!("checking sysroot library: {rust_lib_src}");
|
||||
if fs::metadata(&rust_lib_src).is_ok() {
|
||||
Some(rust_lib_src)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if fs::metadata(&rust_lib_src).is_ok() { Some(rust_lib_src) } else { None }
|
||||
}
|
||||
|
||||
// FIXME: Remove this, that will bump our project MSRV to 1.82
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use base_db::{CrateGraphBuilder, ProcMacroPaths};
|
||||
use cargo_metadata::Metadata;
|
||||
use cfg::{CfgAtom, CfgDiff};
|
||||
use expect_test::{expect_file, ExpectFile};
|
||||
use expect_test::{ExpectFile, expect_file};
|
||||
use intern::sym;
|
||||
use paths::{AbsPath, AbsPathBuf, Utf8Path, Utf8PathBuf};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
|
@ -10,9 +10,9 @@ use span::FileId;
|
|||
use triomphe::Arc;
|
||||
|
||||
use crate::{
|
||||
sysroot::RustLibSrcWorkspace, workspace::ProjectWorkspaceKind, CargoWorkspace, CfgOverrides,
|
||||
ManifestPath, ProjectJson, ProjectJsonData, ProjectWorkspace, RustSourceWorkspaceConfig,
|
||||
Sysroot, WorkspaceBuildScripts,
|
||||
CargoWorkspace, CfgOverrides, ManifestPath, ProjectJson, ProjectJsonData, ProjectWorkspace,
|
||||
RustSourceWorkspaceConfig, Sysroot, WorkspaceBuildScripts, sysroot::RustLibSrcWorkspace,
|
||||
workspace::ProjectWorkspaceKind,
|
||||
};
|
||||
|
||||
fn load_cargo(file: &str) -> (CrateGraphBuilder, ProcMacroPaths) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use anyhow::Context;
|
|||
use rustc_hash::FxHashMap;
|
||||
use toolchain::Tool;
|
||||
|
||||
use crate::{toolchain_info::QueryConfig, utf8_stdout, Sysroot};
|
||||
use crate::{Sysroot, toolchain_info::QueryConfig, utf8_stdout};
|
||||
|
||||
/// Uses `rustc --print target-spec-json`.
|
||||
pub fn get(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use anyhow::Context;
|
|||
use rustc_hash::FxHashMap;
|
||||
use toolchain::Tool;
|
||||
|
||||
use crate::{toolchain_info::QueryConfig, utf8_stdout, ManifestPath, Sysroot};
|
||||
use crate::{ManifestPath, Sysroot, toolchain_info::QueryConfig, utf8_stdout};
|
||||
|
||||
/// For cargo, runs `cargo -Zunstable-options config get build.target` to get the configured project target(s).
|
||||
/// For rustc, runs `rustc --print -vV` to get the host target.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use base_db::{
|
|||
TargetLayoutLoadResult,
|
||||
};
|
||||
use cfg::{CfgAtom, CfgDiff, CfgOptions};
|
||||
use intern::{sym, Symbol};
|
||||
use intern::{Symbol, sym};
|
||||
use paths::{AbsPath, AbsPathBuf};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use semver::Version;
|
||||
|
|
@ -20,15 +20,15 @@ use tracing::instrument;
|
|||
use triomphe::Arc;
|
||||
|
||||
use crate::{
|
||||
CargoConfig, CargoWorkspace, CfgOverrides, InvocationStrategy, ManifestPath, Package,
|
||||
ProjectJson, ProjectManifest, RustSourceWorkspaceConfig, Sysroot, TargetData, TargetKind,
|
||||
WorkspaceBuildScripts,
|
||||
build_dependencies::BuildScriptOutput,
|
||||
cargo_workspace::{CargoMetadataConfig, DepKind, PackageData, RustLibSource},
|
||||
env::{cargo_config_env, inject_cargo_env, inject_cargo_package_env, inject_rustc_tool_env},
|
||||
project_json::{Crate, CrateArrayIdx},
|
||||
sysroot::RustLibSrcWorkspace,
|
||||
toolchain_info::{rustc_cfg, target_data_layout, target_tuple, version, QueryConfig},
|
||||
CargoConfig, CargoWorkspace, CfgOverrides, InvocationStrategy, ManifestPath, Package,
|
||||
ProjectJson, ProjectManifest, RustSourceWorkspaceConfig, Sysroot, TargetData, TargetKind,
|
||||
WorkspaceBuildScripts,
|
||||
toolchain_info::{QueryConfig, rustc_cfg, target_data_layout, target_tuple, version},
|
||||
};
|
||||
use tracing::{debug, error, info};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue