6 use base_db::{CrateGraph, FileId};
7 use cfg::{CfgAtom, CfgDiff};
8 use expect_test::{expect, Expect};
9 use paths::{AbsPath, AbsPathBuf};
10 use serde::de::DeserializeOwned;
13 CargoWorkspace, CfgOverrides, ProjectJson, ProjectJsonData, ProjectWorkspace, Sysroot,
14 WorkspaceBuildScripts,
17 fn load_cargo(file: &str) -> CrateGraph {
18 load_cargo_with_overrides(file, CfgOverrides::default())
21 fn load_cargo_with_overrides(file: &str, cfg_overrides: CfgOverrides) -> CrateGraph {
22 let meta = get_test_json_file(file);
23 let cargo_workspace = CargoWorkspace::new(meta);
24 let project_workspace = ProjectWorkspace::Cargo {
25 cargo: cargo_workspace,
26 build_scripts: WorkspaceBuildScripts::default(),
29 rustc_cfg: Vec::new(),
32 to_crate_graph(project_workspace)
35 fn load_rust_project(file: &str) -> CrateGraph {
36 let data = get_test_json_file(file);
37 let project = rooted_project_json(data);
38 let sysroot = Some(get_fake_sysroot());
39 let project_workspace = ProjectWorkspace::Json { project, sysroot, rustc_cfg: Vec::new() };
40 to_crate_graph(project_workspace)
43 fn get_test_json_file<T: DeserializeOwned>(file: &str) -> T {
44 let file = get_test_path(file);
45 let data = std::fs::read_to_string(file).unwrap();
46 let mut json = data.parse::<serde_json::Value>().unwrap();
47 fixup_paths(&mut json);
48 return serde_json::from_value(json).unwrap();
50 fn fixup_paths(val: &mut serde_json::Value) {
52 serde_json::Value::String(s) => replace_root(s, true),
53 serde_json::Value::Array(vals) => vals.iter_mut().for_each(fixup_paths),
54 serde_json::Value::Object(kvals) => kvals.values_mut().for_each(fixup_paths),
55 serde_json::Value::Null | serde_json::Value::Bool(_) | serde_json::Value::Number(_) => {
61 fn replace_root(s: &mut String, direction: bool) {
63 let root = if cfg!(windows) { r#"C:\\ROOT\"# } else { "/ROOT/" };
64 *s = s.replace("$ROOT$", root)
66 let root = if cfg!(windows) { r#"C:\\\\ROOT\\"# } else { "/ROOT/" };
67 *s = s.replace(root, "$ROOT$")
71 fn get_test_path(file: &str) -> PathBuf {
72 let base = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
73 base.join("test_data").join(file)
76 fn get_fake_sysroot() -> Sysroot {
77 let sysroot_path = get_test_path("fake-sysroot");
78 let sysroot_src_dir = AbsPathBuf::assert(sysroot_path);
79 Sysroot::load(sysroot_src_dir).unwrap()
82 fn rooted_project_json(data: ProjectJsonData) -> ProjectJson {
83 let mut root = "$ROOT$".to_string();
84 replace_root(&mut root, true);
85 let path = Path::new(&root);
86 let base = AbsPath::assert(path);
87 ProjectJson::new(base, data)
90 fn to_crate_graph(project_workspace: ProjectWorkspace) -> CrateGraph {
91 project_workspace.to_crate_graph(&mut |_, _| Vec::new(), &mut {
100 fn check_crate_graph(crate_graph: CrateGraph, expect: Expect) {
101 let mut crate_graph = format!("{:#?}", crate_graph);
102 replace_root(&mut crate_graph, false);
103 expect.assert_eq(&crate_graph);
107 fn cargo_hello_world_project_model_with_wildcard_overrides() {
108 let cfg_overrides = CfgOverrides::Wildcard(
109 CfgDiff::new(Vec::new(), vec![CfgAtom::Flag("test".into())]).unwrap(),
111 let crate_graph = load_cargo_with_overrides("hello-world-metadata.json", cfg_overrides);
120 root_file_id: FileId(
123 edition: Edition2018,
129 crate_name: CrateName(
132 canonical_name: "hello-world",
135 cfg_options: CfgOptions(
140 potential_cfg_options: CfgOptions(
147 "CARGO_PKG_LICENSE": "",
148 "CARGO_PKG_VERSION_MAJOR": "0",
149 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
150 "CARGO_PKG_VERSION": "0.1.0",
151 "CARGO_PKG_AUTHORS": "",
152 "CARGO_CRATE_NAME": "hello_world",
153 "CARGO_PKG_LICENSE_FILE": "",
154 "CARGO_PKG_HOMEPAGE": "",
155 "CARGO_PKG_DESCRIPTION": "",
156 "CARGO_PKG_NAME": "hello-world",
157 "CARGO_PKG_VERSION_PATCH": "0",
159 "CARGO_PKG_REPOSITORY": "",
160 "CARGO_PKG_VERSION_MINOR": "1",
161 "CARGO_PKG_VERSION_PRE": "",
179 is_proc_macro: false,
184 root_file_id: FileId(
187 edition: Edition2018,
193 crate_name: CrateName(
196 canonical_name: "an-example",
199 cfg_options: CfgOptions(
204 potential_cfg_options: CfgOptions(
211 "CARGO_PKG_LICENSE": "",
212 "CARGO_PKG_VERSION_MAJOR": "0",
213 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
214 "CARGO_PKG_VERSION": "0.1.0",
215 "CARGO_PKG_AUTHORS": "",
216 "CARGO_CRATE_NAME": "hello_world",
217 "CARGO_PKG_LICENSE_FILE": "",
218 "CARGO_PKG_HOMEPAGE": "",
219 "CARGO_PKG_DESCRIPTION": "",
220 "CARGO_PKG_NAME": "hello-world",
221 "CARGO_PKG_VERSION_PATCH": "0",
223 "CARGO_PKG_REPOSITORY": "",
224 "CARGO_PKG_VERSION_MINOR": "1",
225 "CARGO_PKG_VERSION_PRE": "",
252 is_proc_macro: false,
257 root_file_id: FileId(
260 edition: Edition2015,
266 crate_name: CrateName(
269 canonical_name: "libc",
272 cfg_options: CfgOptions(
279 potential_cfg_options: CfgOptions(
283 "feature=const-extern-fn",
285 "feature=extra_traits",
286 "feature=rustc-dep-of-std",
293 "CARGO_PKG_LICENSE": "",
294 "CARGO_PKG_VERSION_MAJOR": "0",
295 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
296 "CARGO_PKG_VERSION": "0.2.98",
297 "CARGO_PKG_AUTHORS": "",
298 "CARGO_CRATE_NAME": "libc",
299 "CARGO_PKG_LICENSE_FILE": "",
300 "CARGO_PKG_HOMEPAGE": "",
301 "CARGO_PKG_DESCRIPTION": "",
302 "CARGO_PKG_NAME": "libc",
303 "CARGO_PKG_VERSION_PATCH": "98",
305 "CARGO_PKG_REPOSITORY": "",
306 "CARGO_PKG_VERSION_MINOR": "2",
307 "CARGO_PKG_VERSION_PRE": "",
314 "https://github.com/rust-lang/libc",
317 is_proc_macro: false,
322 root_file_id: FileId(
325 edition: Edition2018,
331 crate_name: CrateName(
334 canonical_name: "hello-world",
337 cfg_options: CfgOptions(
342 potential_cfg_options: CfgOptions(
349 "CARGO_PKG_LICENSE": "",
350 "CARGO_PKG_VERSION_MAJOR": "0",
351 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
352 "CARGO_PKG_VERSION": "0.1.0",
353 "CARGO_PKG_AUTHORS": "",
354 "CARGO_CRATE_NAME": "hello_world",
355 "CARGO_PKG_LICENSE_FILE": "",
356 "CARGO_PKG_HOMEPAGE": "",
357 "CARGO_PKG_DESCRIPTION": "",
358 "CARGO_PKG_NAME": "hello-world",
359 "CARGO_PKG_VERSION_PATCH": "0",
361 "CARGO_PKG_REPOSITORY": "",
362 "CARGO_PKG_VERSION_MINOR": "1",
363 "CARGO_PKG_VERSION_PRE": "",
390 is_proc_macro: false,
395 root_file_id: FileId(
398 edition: Edition2018,
404 crate_name: CrateName(
407 canonical_name: "it",
410 cfg_options: CfgOptions(
415 potential_cfg_options: CfgOptions(
422 "CARGO_PKG_LICENSE": "",
423 "CARGO_PKG_VERSION_MAJOR": "0",
424 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
425 "CARGO_PKG_VERSION": "0.1.0",
426 "CARGO_PKG_AUTHORS": "",
427 "CARGO_CRATE_NAME": "hello_world",
428 "CARGO_PKG_LICENSE_FILE": "",
429 "CARGO_PKG_HOMEPAGE": "",
430 "CARGO_PKG_DESCRIPTION": "",
431 "CARGO_PKG_NAME": "hello-world",
432 "CARGO_PKG_VERSION_PATCH": "0",
434 "CARGO_PKG_REPOSITORY": "",
435 "CARGO_PKG_VERSION_MINOR": "1",
436 "CARGO_PKG_VERSION_PRE": "",
463 is_proc_macro: false,
471 fn cargo_hello_world_project_model_with_selective_overrides() {
472 let cfg_overrides = {
473 CfgOverrides::Selective(
476 CfgDiff::new(Vec::new(), vec![CfgAtom::Flag("test".into())]).unwrap(),
481 let crate_graph = load_cargo_with_overrides("hello-world-metadata.json", cfg_overrides);
490 root_file_id: FileId(
493 edition: Edition2018,
499 crate_name: CrateName(
502 canonical_name: "hello-world",
505 cfg_options: CfgOptions(
511 potential_cfg_options: CfgOptions(
519 "CARGO_PKG_LICENSE": "",
520 "CARGO_PKG_VERSION_MAJOR": "0",
521 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
522 "CARGO_PKG_VERSION": "0.1.0",
523 "CARGO_PKG_AUTHORS": "",
524 "CARGO_CRATE_NAME": "hello_world",
525 "CARGO_PKG_LICENSE_FILE": "",
526 "CARGO_PKG_HOMEPAGE": "",
527 "CARGO_PKG_DESCRIPTION": "",
528 "CARGO_PKG_NAME": "hello-world",
529 "CARGO_PKG_VERSION_PATCH": "0",
531 "CARGO_PKG_REPOSITORY": "",
532 "CARGO_PKG_VERSION_MINOR": "1",
533 "CARGO_PKG_VERSION_PRE": "",
551 is_proc_macro: false,
556 root_file_id: FileId(
559 edition: Edition2018,
565 crate_name: CrateName(
568 canonical_name: "an-example",
571 cfg_options: CfgOptions(
577 potential_cfg_options: CfgOptions(
585 "CARGO_PKG_LICENSE": "",
586 "CARGO_PKG_VERSION_MAJOR": "0",
587 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
588 "CARGO_PKG_VERSION": "0.1.0",
589 "CARGO_PKG_AUTHORS": "",
590 "CARGO_CRATE_NAME": "hello_world",
591 "CARGO_PKG_LICENSE_FILE": "",
592 "CARGO_PKG_HOMEPAGE": "",
593 "CARGO_PKG_DESCRIPTION": "",
594 "CARGO_PKG_NAME": "hello-world",
595 "CARGO_PKG_VERSION_PATCH": "0",
597 "CARGO_PKG_REPOSITORY": "",
598 "CARGO_PKG_VERSION_MINOR": "1",
599 "CARGO_PKG_VERSION_PRE": "",
626 is_proc_macro: false,
631 root_file_id: FileId(
634 edition: Edition2015,
640 crate_name: CrateName(
643 canonical_name: "libc",
646 cfg_options: CfgOptions(
653 potential_cfg_options: CfgOptions(
657 "feature=const-extern-fn",
659 "feature=extra_traits",
660 "feature=rustc-dep-of-std",
667 "CARGO_PKG_LICENSE": "",
668 "CARGO_PKG_VERSION_MAJOR": "0",
669 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
670 "CARGO_PKG_VERSION": "0.2.98",
671 "CARGO_PKG_AUTHORS": "",
672 "CARGO_CRATE_NAME": "libc",
673 "CARGO_PKG_LICENSE_FILE": "",
674 "CARGO_PKG_HOMEPAGE": "",
675 "CARGO_PKG_DESCRIPTION": "",
676 "CARGO_PKG_NAME": "libc",
677 "CARGO_PKG_VERSION_PATCH": "98",
679 "CARGO_PKG_REPOSITORY": "",
680 "CARGO_PKG_VERSION_MINOR": "2",
681 "CARGO_PKG_VERSION_PRE": "",
688 "https://github.com/rust-lang/libc",
691 is_proc_macro: false,
696 root_file_id: FileId(
699 edition: Edition2018,
705 crate_name: CrateName(
708 canonical_name: "hello-world",
711 cfg_options: CfgOptions(
717 potential_cfg_options: CfgOptions(
725 "CARGO_PKG_LICENSE": "",
726 "CARGO_PKG_VERSION_MAJOR": "0",
727 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
728 "CARGO_PKG_VERSION": "0.1.0",
729 "CARGO_PKG_AUTHORS": "",
730 "CARGO_CRATE_NAME": "hello_world",
731 "CARGO_PKG_LICENSE_FILE": "",
732 "CARGO_PKG_HOMEPAGE": "",
733 "CARGO_PKG_DESCRIPTION": "",
734 "CARGO_PKG_NAME": "hello-world",
735 "CARGO_PKG_VERSION_PATCH": "0",
737 "CARGO_PKG_REPOSITORY": "",
738 "CARGO_PKG_VERSION_MINOR": "1",
739 "CARGO_PKG_VERSION_PRE": "",
766 is_proc_macro: false,
771 root_file_id: FileId(
774 edition: Edition2018,
780 crate_name: CrateName(
783 canonical_name: "it",
786 cfg_options: CfgOptions(
792 potential_cfg_options: CfgOptions(
800 "CARGO_PKG_LICENSE": "",
801 "CARGO_PKG_VERSION_MAJOR": "0",
802 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
803 "CARGO_PKG_VERSION": "0.1.0",
804 "CARGO_PKG_AUTHORS": "",
805 "CARGO_CRATE_NAME": "hello_world",
806 "CARGO_PKG_LICENSE_FILE": "",
807 "CARGO_PKG_HOMEPAGE": "",
808 "CARGO_PKG_DESCRIPTION": "",
809 "CARGO_PKG_NAME": "hello-world",
810 "CARGO_PKG_VERSION_PATCH": "0",
812 "CARGO_PKG_REPOSITORY": "",
813 "CARGO_PKG_VERSION_MINOR": "1",
814 "CARGO_PKG_VERSION_PRE": "",
841 is_proc_macro: false,
849 fn cargo_hello_world_project_model() {
850 let crate_graph = load_cargo("hello-world-metadata.json");
859 root_file_id: FileId(
862 edition: Edition2018,
868 crate_name: CrateName(
871 canonical_name: "hello-world",
874 cfg_options: CfgOptions(
880 potential_cfg_options: CfgOptions(
888 "CARGO_PKG_LICENSE": "",
889 "CARGO_PKG_VERSION_MAJOR": "0",
890 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
891 "CARGO_PKG_VERSION": "0.1.0",
892 "CARGO_PKG_AUTHORS": "",
893 "CARGO_CRATE_NAME": "hello_world",
894 "CARGO_PKG_LICENSE_FILE": "",
895 "CARGO_PKG_HOMEPAGE": "",
896 "CARGO_PKG_DESCRIPTION": "",
897 "CARGO_PKG_NAME": "hello-world",
898 "CARGO_PKG_VERSION_PATCH": "0",
900 "CARGO_PKG_REPOSITORY": "",
901 "CARGO_PKG_VERSION_MINOR": "1",
902 "CARGO_PKG_VERSION_PRE": "",
920 is_proc_macro: false,
925 root_file_id: FileId(
928 edition: Edition2018,
934 crate_name: CrateName(
937 canonical_name: "an-example",
940 cfg_options: CfgOptions(
946 potential_cfg_options: CfgOptions(
954 "CARGO_PKG_LICENSE": "",
955 "CARGO_PKG_VERSION_MAJOR": "0",
956 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
957 "CARGO_PKG_VERSION": "0.1.0",
958 "CARGO_PKG_AUTHORS": "",
959 "CARGO_CRATE_NAME": "hello_world",
960 "CARGO_PKG_LICENSE_FILE": "",
961 "CARGO_PKG_HOMEPAGE": "",
962 "CARGO_PKG_DESCRIPTION": "",
963 "CARGO_PKG_NAME": "hello-world",
964 "CARGO_PKG_VERSION_PATCH": "0",
966 "CARGO_PKG_REPOSITORY": "",
967 "CARGO_PKG_VERSION_MINOR": "1",
968 "CARGO_PKG_VERSION_PRE": "",
995 is_proc_macro: false,
1000 root_file_id: FileId(
1003 edition: Edition2015,
1009 crate_name: CrateName(
1012 canonical_name: "libc",
1015 cfg_options: CfgOptions(
1023 potential_cfg_options: CfgOptions(
1027 "feature=const-extern-fn",
1029 "feature=extra_traits",
1030 "feature=rustc-dep-of-std",
1038 "CARGO_PKG_LICENSE": "",
1039 "CARGO_PKG_VERSION_MAJOR": "0",
1040 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
1041 "CARGO_PKG_VERSION": "0.2.98",
1042 "CARGO_PKG_AUTHORS": "",
1043 "CARGO_CRATE_NAME": "libc",
1044 "CARGO_PKG_LICENSE_FILE": "",
1045 "CARGO_PKG_HOMEPAGE": "",
1046 "CARGO_PKG_DESCRIPTION": "",
1047 "CARGO_PKG_NAME": "libc",
1048 "CARGO_PKG_VERSION_PATCH": "98",
1050 "CARGO_PKG_REPOSITORY": "",
1051 "CARGO_PKG_VERSION_MINOR": "2",
1052 "CARGO_PKG_VERSION_PRE": "",
1059 "https://github.com/rust-lang/libc",
1062 is_proc_macro: false,
1067 root_file_id: FileId(
1070 edition: Edition2018,
1076 crate_name: CrateName(
1079 canonical_name: "hello-world",
1082 cfg_options: CfgOptions(
1088 potential_cfg_options: CfgOptions(
1096 "CARGO_PKG_LICENSE": "",
1097 "CARGO_PKG_VERSION_MAJOR": "0",
1098 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
1099 "CARGO_PKG_VERSION": "0.1.0",
1100 "CARGO_PKG_AUTHORS": "",
1101 "CARGO_CRATE_NAME": "hello_world",
1102 "CARGO_PKG_LICENSE_FILE": "",
1103 "CARGO_PKG_HOMEPAGE": "",
1104 "CARGO_PKG_DESCRIPTION": "",
1105 "CARGO_PKG_NAME": "hello-world",
1106 "CARGO_PKG_VERSION_PATCH": "0",
1108 "CARGO_PKG_REPOSITORY": "",
1109 "CARGO_PKG_VERSION_MINOR": "1",
1110 "CARGO_PKG_VERSION_PRE": "",
1137 is_proc_macro: false,
1142 root_file_id: FileId(
1145 edition: Edition2018,
1151 crate_name: CrateName(
1154 canonical_name: "it",
1157 cfg_options: CfgOptions(
1163 potential_cfg_options: CfgOptions(
1171 "CARGO_PKG_LICENSE": "",
1172 "CARGO_PKG_VERSION_MAJOR": "0",
1173 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
1174 "CARGO_PKG_VERSION": "0.1.0",
1175 "CARGO_PKG_AUTHORS": "",
1176 "CARGO_CRATE_NAME": "hello_world",
1177 "CARGO_PKG_LICENSE_FILE": "",
1178 "CARGO_PKG_HOMEPAGE": "",
1179 "CARGO_PKG_DESCRIPTION": "",
1180 "CARGO_PKG_NAME": "hello-world",
1181 "CARGO_PKG_VERSION_PATCH": "0",
1183 "CARGO_PKG_REPOSITORY": "",
1184 "CARGO_PKG_VERSION_MINOR": "1",
1185 "CARGO_PKG_VERSION_PRE": "",
1212 is_proc_macro: false,
1220 fn rust_project_hello_world_project_model() {
1221 let crate_graph = load_rust_project("hello-world-project.json");
1230 root_file_id: FileId(
1233 edition: Edition2018,
1237 crate_name: CrateName(
1240 canonical_name: "alloc",
1243 cfg_options: CfgOptions(
1246 potential_cfg_options: CfgOptions(
1267 is_proc_macro: false,
1272 root_file_id: FileId(
1275 edition: Edition2018,
1279 crate_name: CrateName(
1282 canonical_name: "unwind",
1285 cfg_options: CfgOptions(
1288 potential_cfg_options: CfgOptions(
1299 is_proc_macro: false,
1304 root_file_id: FileId(
1307 edition: Edition2018,
1311 crate_name: CrateName(
1314 canonical_name: "std_detect",
1317 cfg_options: CfgOptions(
1320 potential_cfg_options: CfgOptions(
1331 is_proc_macro: false,
1336 root_file_id: FileId(
1339 edition: Edition2018,
1343 crate_name: CrateName(
1346 canonical_name: "proc_macro",
1349 cfg_options: CfgOptions(
1352 potential_cfg_options: CfgOptions(
1373 is_proc_macro: false,
1378 root_file_id: FileId(
1381 edition: Edition2018,
1385 crate_name: CrateName(
1388 canonical_name: "core",
1391 cfg_options: CfgOptions(
1394 potential_cfg_options: CfgOptions(
1405 is_proc_macro: false,
1410 root_file_id: FileId(
1413 edition: Edition2018,
1417 crate_name: CrateName(
1420 canonical_name: "hello_world",
1423 cfg_options: CfgOptions(
1426 potential_cfg_options: CfgOptions(
1474 is_proc_macro: false,
1479 root_file_id: FileId(
1482 edition: Edition2018,
1486 crate_name: CrateName(
1489 canonical_name: "term",
1492 cfg_options: CfgOptions(
1495 potential_cfg_options: CfgOptions(
1506 is_proc_macro: false,
1511 root_file_id: FileId(
1514 edition: Edition2018,
1518 crate_name: CrateName(
1519 "profiler_builtins",
1521 canonical_name: "profiler_builtins",
1524 cfg_options: CfgOptions(
1527 potential_cfg_options: CfgOptions(
1538 is_proc_macro: false,
1543 root_file_id: FileId(
1546 edition: Edition2018,
1550 crate_name: CrateName(
1553 canonical_name: "panic_abort",
1556 cfg_options: CfgOptions(
1559 potential_cfg_options: CfgOptions(
1570 is_proc_macro: false,
1575 root_file_id: FileId(
1578 edition: Edition2018,
1582 crate_name: CrateName(
1585 canonical_name: "test",
1588 cfg_options: CfgOptions(
1591 potential_cfg_options: CfgOptions(
1602 is_proc_macro: false,
1607 root_file_id: FileId(
1610 edition: Edition2018,
1614 crate_name: CrateName(
1617 canonical_name: "std",
1620 cfg_options: CfgOptions(
1623 potential_cfg_options: CfgOptions(
1671 "profiler_builtins",
1716 is_proc_macro: false,
1721 root_file_id: FileId(
1724 edition: Edition2018,
1728 crate_name: CrateName(
1731 canonical_name: "panic_unwind",
1734 cfg_options: CfgOptions(
1737 potential_cfg_options: CfgOptions(
1748 is_proc_macro: false,
1756 fn rust_project_is_proc_macro_has_proc_macro_dep() {
1757 let crate_graph = load_rust_project("is-proc-macro-project.json");
1758 // Since the project only defines one crate (outside the sysroot crates),
1759 // it should be the one with the biggest Id.
1760 let crate_id = crate_graph.iter().max().unwrap();
1761 let crate_data = &crate_graph[crate_id];
1762 // Assert that the project crate with `is_proc_macro` has a dependency
1763 // on the proc_macro sysroot crate.
1764 crate_data.dependencies.iter().find(|&dep| dep.name.deref() == "proc_macro").unwrap();