mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 05:08:52 +00:00
Merge #11314
11314: fix: Don't load auxiliary crates outside the workspace r=jonas-schievink a=jonas-schievink I'm a bit unsure about this change since this might have unanticipated consequences, but this does fix https://github.com/rust-analyzer/rust-analyzer/issues/11300. Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
This commit is contained in:
commit
6a64d3c4df
2 changed files with 9 additions and 418 deletions
|
@ -177,80 +177,6 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||
repo: None,
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
5,
|
||||
): CrateData {
|
||||
root_file_id: FileId(
|
||||
6,
|
||||
),
|
||||
edition: Edition2015,
|
||||
version: Some(
|
||||
"0.2.98",
|
||||
),
|
||||
display_name: Some(
|
||||
CrateDisplayName {
|
||||
crate_name: CrateName(
|
||||
"const_fn",
|
||||
),
|
||||
canonical_name: "const_fn",
|
||||
},
|
||||
),
|
||||
cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=default",
|
||||
"feature=std",
|
||||
],
|
||||
),
|
||||
potential_cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=align",
|
||||
"feature=const-extern-fn",
|
||||
"feature=default",
|
||||
"feature=extra_traits",
|
||||
"feature=rustc-dep-of-std",
|
||||
"feature=std",
|
||||
"feature=use_std",
|
||||
],
|
||||
),
|
||||
env: Env {
|
||||
entries: {
|
||||
"CARGO_PKG_LICENSE": "",
|
||||
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||
"CARGO_PKG_VERSION": "0.2.98",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "libc",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
"CARGO_PKG_NAME": "libc",
|
||||
"CARGO_PKG_VERSION_PATCH": "98",
|
||||
"CARGO": "cargo",
|
||||
"CARGO_PKG_REPOSITORY": "",
|
||||
"CARGO_PKG_VERSION_MINOR": "2",
|
||||
"CARGO_PKG_VERSION_PRE": "",
|
||||
},
|
||||
},
|
||||
dependencies: [
|
||||
Dependency {
|
||||
crate_id: CrateId(
|
||||
4,
|
||||
),
|
||||
name: CrateName(
|
||||
"libc",
|
||||
),
|
||||
prelude: true,
|
||||
},
|
||||
],
|
||||
proc_macro: [],
|
||||
origin: CratesIo {
|
||||
repo: Some(
|
||||
"https://github.com/rust-lang/libc",
|
||||
),
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
2,
|
||||
): CrateData {
|
||||
|
@ -459,70 +385,6 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||
repo: None,
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
6,
|
||||
): CrateData {
|
||||
root_file_id: FileId(
|
||||
7,
|
||||
),
|
||||
edition: Edition2015,
|
||||
version: Some(
|
||||
"0.2.98",
|
||||
),
|
||||
display_name: Some(
|
||||
CrateDisplayName {
|
||||
crate_name: CrateName(
|
||||
"build_script_build",
|
||||
),
|
||||
canonical_name: "build-script-build",
|
||||
},
|
||||
),
|
||||
cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=default",
|
||||
"feature=std",
|
||||
],
|
||||
),
|
||||
potential_cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=align",
|
||||
"feature=const-extern-fn",
|
||||
"feature=default",
|
||||
"feature=extra_traits",
|
||||
"feature=rustc-dep-of-std",
|
||||
"feature=std",
|
||||
"feature=use_std",
|
||||
],
|
||||
),
|
||||
env: Env {
|
||||
entries: {
|
||||
"CARGO_PKG_LICENSE": "",
|
||||
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||
"CARGO_PKG_VERSION": "0.2.98",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "libc",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
"CARGO_PKG_NAME": "libc",
|
||||
"CARGO_PKG_VERSION_PATCH": "98",
|
||||
"CARGO": "cargo",
|
||||
"CARGO_PKG_REPOSITORY": "",
|
||||
"CARGO_PKG_VERSION_MINOR": "2",
|
||||
"CARGO_PKG_VERSION_PRE": "",
|
||||
},
|
||||
},
|
||||
dependencies: [],
|
||||
proc_macro: [],
|
||||
origin: CratesIo {
|
||||
repo: Some(
|
||||
"https://github.com/rust-lang/libc",
|
||||
),
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
3,
|
||||
): CrateData {
|
||||
|
@ -682,80 +544,6 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||
repo: None,
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
5,
|
||||
): CrateData {
|
||||
root_file_id: FileId(
|
||||
6,
|
||||
),
|
||||
edition: Edition2015,
|
||||
version: Some(
|
||||
"0.2.98",
|
||||
),
|
||||
display_name: Some(
|
||||
CrateDisplayName {
|
||||
crate_name: CrateName(
|
||||
"const_fn",
|
||||
),
|
||||
canonical_name: "const_fn",
|
||||
},
|
||||
),
|
||||
cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=default",
|
||||
"feature=std",
|
||||
],
|
||||
),
|
||||
potential_cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=align",
|
||||
"feature=const-extern-fn",
|
||||
"feature=default",
|
||||
"feature=extra_traits",
|
||||
"feature=rustc-dep-of-std",
|
||||
"feature=std",
|
||||
"feature=use_std",
|
||||
],
|
||||
),
|
||||
env: Env {
|
||||
entries: {
|
||||
"CARGO_PKG_LICENSE": "",
|
||||
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||
"CARGO_PKG_VERSION": "0.2.98",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "libc",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
"CARGO_PKG_NAME": "libc",
|
||||
"CARGO_PKG_VERSION_PATCH": "98",
|
||||
"CARGO": "cargo",
|
||||
"CARGO_PKG_REPOSITORY": "",
|
||||
"CARGO_PKG_VERSION_MINOR": "2",
|
||||
"CARGO_PKG_VERSION_PRE": "",
|
||||
},
|
||||
},
|
||||
dependencies: [
|
||||
Dependency {
|
||||
crate_id: CrateId(
|
||||
4,
|
||||
),
|
||||
name: CrateName(
|
||||
"libc",
|
||||
),
|
||||
prelude: true,
|
||||
},
|
||||
],
|
||||
proc_macro: [],
|
||||
origin: CratesIo {
|
||||
repo: Some(
|
||||
"https://github.com/rust-lang/libc",
|
||||
),
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
2,
|
||||
): CrateData {
|
||||
|
@ -968,70 +756,6 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||
repo: None,
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
6,
|
||||
): CrateData {
|
||||
root_file_id: FileId(
|
||||
7,
|
||||
),
|
||||
edition: Edition2015,
|
||||
version: Some(
|
||||
"0.2.98",
|
||||
),
|
||||
display_name: Some(
|
||||
CrateDisplayName {
|
||||
crate_name: CrateName(
|
||||
"build_script_build",
|
||||
),
|
||||
canonical_name: "build-script-build",
|
||||
},
|
||||
),
|
||||
cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=default",
|
||||
"feature=std",
|
||||
],
|
||||
),
|
||||
potential_cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=align",
|
||||
"feature=const-extern-fn",
|
||||
"feature=default",
|
||||
"feature=extra_traits",
|
||||
"feature=rustc-dep-of-std",
|
||||
"feature=std",
|
||||
"feature=use_std",
|
||||
],
|
||||
),
|
||||
env: Env {
|
||||
entries: {
|
||||
"CARGO_PKG_LICENSE": "",
|
||||
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||
"CARGO_PKG_VERSION": "0.2.98",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "libc",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
"CARGO_PKG_NAME": "libc",
|
||||
"CARGO_PKG_VERSION_PATCH": "98",
|
||||
"CARGO": "cargo",
|
||||
"CARGO_PKG_REPOSITORY": "",
|
||||
"CARGO_PKG_VERSION_MINOR": "2",
|
||||
"CARGO_PKG_VERSION_PRE": "",
|
||||
},
|
||||
},
|
||||
dependencies: [],
|
||||
proc_macro: [],
|
||||
origin: CratesIo {
|
||||
repo: Some(
|
||||
"https://github.com/rust-lang/libc",
|
||||
),
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
3,
|
||||
): CrateData {
|
||||
|
@ -1184,82 +908,6 @@ fn cargo_hello_world_project_model() {
|
|||
repo: None,
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
5,
|
||||
): CrateData {
|
||||
root_file_id: FileId(
|
||||
6,
|
||||
),
|
||||
edition: Edition2015,
|
||||
version: Some(
|
||||
"0.2.98",
|
||||
),
|
||||
display_name: Some(
|
||||
CrateDisplayName {
|
||||
crate_name: CrateName(
|
||||
"const_fn",
|
||||
),
|
||||
canonical_name: "const_fn",
|
||||
},
|
||||
),
|
||||
cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=default",
|
||||
"feature=std",
|
||||
"test",
|
||||
],
|
||||
),
|
||||
potential_cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=align",
|
||||
"feature=const-extern-fn",
|
||||
"feature=default",
|
||||
"feature=extra_traits",
|
||||
"feature=rustc-dep-of-std",
|
||||
"feature=std",
|
||||
"feature=use_std",
|
||||
"test",
|
||||
],
|
||||
),
|
||||
env: Env {
|
||||
entries: {
|
||||
"CARGO_PKG_LICENSE": "",
|
||||
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||
"CARGO_PKG_VERSION": "0.2.98",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "libc",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
"CARGO_PKG_NAME": "libc",
|
||||
"CARGO_PKG_VERSION_PATCH": "98",
|
||||
"CARGO": "cargo",
|
||||
"CARGO_PKG_REPOSITORY": "",
|
||||
"CARGO_PKG_VERSION_MINOR": "2",
|
||||
"CARGO_PKG_VERSION_PRE": "",
|
||||
},
|
||||
},
|
||||
dependencies: [
|
||||
Dependency {
|
||||
crate_id: CrateId(
|
||||
4,
|
||||
),
|
||||
name: CrateName(
|
||||
"libc",
|
||||
),
|
||||
prelude: true,
|
||||
},
|
||||
],
|
||||
proc_macro: [],
|
||||
origin: CratesIo {
|
||||
repo: Some(
|
||||
"https://github.com/rust-lang/libc",
|
||||
),
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
2,
|
||||
): CrateData {
|
||||
|
@ -1474,72 +1122,6 @@ fn cargo_hello_world_project_model() {
|
|||
repo: None,
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
6,
|
||||
): CrateData {
|
||||
root_file_id: FileId(
|
||||
7,
|
||||
),
|
||||
edition: Edition2015,
|
||||
version: Some(
|
||||
"0.2.98",
|
||||
),
|
||||
display_name: Some(
|
||||
CrateDisplayName {
|
||||
crate_name: CrateName(
|
||||
"build_script_build",
|
||||
),
|
||||
canonical_name: "build-script-build",
|
||||
},
|
||||
),
|
||||
cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=default",
|
||||
"feature=std",
|
||||
"test",
|
||||
],
|
||||
),
|
||||
potential_cfg_options: CfgOptions(
|
||||
[
|
||||
"debug_assertions",
|
||||
"feature=align",
|
||||
"feature=const-extern-fn",
|
||||
"feature=default",
|
||||
"feature=extra_traits",
|
||||
"feature=rustc-dep-of-std",
|
||||
"feature=std",
|
||||
"feature=use_std",
|
||||
"test",
|
||||
],
|
||||
),
|
||||
env: Env {
|
||||
entries: {
|
||||
"CARGO_PKG_LICENSE": "",
|
||||
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||
"CARGO_PKG_VERSION": "0.2.98",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "libc",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
"CARGO_PKG_NAME": "libc",
|
||||
"CARGO_PKG_VERSION_PATCH": "98",
|
||||
"CARGO": "cargo",
|
||||
"CARGO_PKG_REPOSITORY": "",
|
||||
"CARGO_PKG_VERSION_MINOR": "2",
|
||||
"CARGO_PKG_VERSION_PRE": "",
|
||||
},
|
||||
},
|
||||
dependencies: [],
|
||||
proc_macro: [],
|
||||
origin: CratesIo {
|
||||
repo: Some(
|
||||
"https://github.com/rust-lang/libc",
|
||||
),
|
||||
},
|
||||
},
|
||||
CrateId(
|
||||
3,
|
||||
): CrateData {
|
||||
|
|
|
@ -574,6 +574,15 @@ fn cargo_to_crate_graph(
|
|||
has_private |= cargo[pkg].metadata.rustc_private;
|
||||
let mut lib_tgt = None;
|
||||
for &tgt in cargo[pkg].targets.iter() {
|
||||
if cargo[tgt].kind != TargetKind::Lib && !cargo[pkg].is_member {
|
||||
// For non-workspace-members, Cargo does not resolve dev-dependencies, so we don't
|
||||
// add any targets except the library target, since those will not work correctly if
|
||||
// they use dev-dependencies.
|
||||
// In fact, they can break quite badly if multiple client workspaces get merged:
|
||||
// https://github.com/rust-analyzer/rust-analyzer/issues/11300
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(file_id) = load(&cargo[tgt].root) {
|
||||
let crate_id = add_target_crate_root(
|
||||
&mut crate_graph,
|
||||
|
|
Loading…
Reference in a new issue