mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-04 18:58:41 +00:00
feat(project-model): provide flag for no deps
A Cargo project can now be built without any dependency metadata being fetched. Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
This commit is contained in:
parent
6ca780700d
commit
865681d779
6 changed files with 31 additions and 2 deletions
|
@ -108,7 +108,10 @@ pub struct CargoConfig {
|
|||
pub invocation_strategy: InvocationStrategy,
|
||||
/// Optional path to use instead of `target` when building
|
||||
pub target_dir: Option<Utf8PathBuf>,
|
||||
/// Gate `#[test]` behind `#[cfg(test)]`
|
||||
pub set_test: bool,
|
||||
/// Load the project without any dependencies
|
||||
pub no_deps: bool,
|
||||
}
|
||||
|
||||
pub type Package = Idx<PackageData>;
|
||||
|
@ -308,6 +311,7 @@ impl CargoWorkspace {
|
|||
current_dir: &AbsPath,
|
||||
config: &CargoMetadataConfig,
|
||||
sysroot: &Sysroot,
|
||||
no_deps: bool,
|
||||
locked: bool,
|
||||
progress: &dyn Fn(String),
|
||||
) -> anyhow::Result<(cargo_metadata::Metadata, Option<anyhow::Error>)> {
|
||||
|
@ -316,8 +320,8 @@ impl CargoWorkspace {
|
|||
current_dir,
|
||||
config,
|
||||
sysroot,
|
||||
no_deps,
|
||||
locked,
|
||||
false,
|
||||
progress,
|
||||
);
|
||||
if let Ok((_, Some(ref e))) = res {
|
||||
|
@ -335,8 +339,8 @@ impl CargoWorkspace {
|
|||
current_dir: &AbsPath,
|
||||
config: &CargoMetadataConfig,
|
||||
sysroot: &Sysroot,
|
||||
locked: bool,
|
||||
no_deps: bool,
|
||||
locked: bool,
|
||||
progress: &dyn Fn(String),
|
||||
) -> anyhow::Result<(cargo_metadata::Metadata, Option<anyhow::Error>)> {
|
||||
let cargo = sysroot.tool(Tool::Cargo, current_dir);
|
||||
|
|
|
@ -300,6 +300,7 @@ impl Sysroot {
|
|||
rust_lib_src_dir,
|
||||
&cargo_config,
|
||||
self,
|
||||
false,
|
||||
// Make sure we never attempt to write to the sysroot
|
||||
true,
|
||||
&|_| (),
|
||||
|
|
|
@ -220,6 +220,7 @@ impl ProjectWorkspace {
|
|||
sysroot,
|
||||
sysroot_src,
|
||||
target,
|
||||
no_deps,
|
||||
..
|
||||
} = config;
|
||||
let mut sysroot = match (sysroot, sysroot_src) {
|
||||
|
@ -301,6 +302,7 @@ impl ProjectWorkspace {
|
|||
extra_env: extra_env.clone(),
|
||||
},
|
||||
&sysroot,
|
||||
*no_deps,
|
||||
false,
|
||||
&|_| (),
|
||||
) {
|
||||
|
@ -343,6 +345,7 @@ impl ProjectWorkspace {
|
|||
extra_env: extra_env.clone(),
|
||||
},
|
||||
&sysroot,
|
||||
*no_deps,
|
||||
false,
|
||||
&|_| (),
|
||||
)
|
||||
|
@ -511,6 +514,7 @@ impl ProjectWorkspace {
|
|||
extra_env: config.extra_env.clone(),
|
||||
},
|
||||
&sysroot,
|
||||
config.no_deps,
|
||||
false,
|
||||
&|_| (),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue