aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_db/src/input.rs35
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs2
-rw-r--r--editors/code/src/net.ts5
3 files changed, 33 insertions, 9 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index bf26048f2..e6af99035 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -254,12 +254,12 @@ impl CrateGraph {
254 return false; 254 return false;
255 } 255 }
256 256
257 if target == from {
258 return true;
259 }
260
257 for dep in &self[from].dependencies { 261 for dep in &self[from].dependencies {
258 let crate_id = dep.crate_id; 262 let crate_id = dep.crate_id;
259 if crate_id == target {
260 return true;
261 }
262
263 if self.dfs_find(target, crate_id, visited) { 263 if self.dfs_find(target, crate_id, visited) {
264 return true; 264 return true;
265 } 265 }
@@ -369,7 +369,7 @@ mod tests {
369 use super::{CfgOptions, CrateGraph, CrateName, Dependency, Edition::Edition2018, Env, FileId}; 369 use super::{CfgOptions, CrateGraph, CrateName, Dependency, Edition::Edition2018, Env, FileId};
370 370
371 #[test] 371 #[test]
372 fn it_should_panic_because_of_cycle_dependencies() { 372 fn detect_cyclic_dependency_indirect() {
373 let mut graph = CrateGraph::default(); 373 let mut graph = CrateGraph::default();
374 let crate1 = graph.add_crate_root( 374 let crate1 = graph.add_crate_root(
375 FileId(1u32), 375 FileId(1u32),
@@ -404,6 +404,31 @@ mod tests {
404 } 404 }
405 405
406 #[test] 406 #[test]
407 fn detect_cyclic_dependency_direct() {
408 let mut graph = CrateGraph::default();
409 let crate1 = graph.add_crate_root(
410 FileId(1u32),
411 Edition2018,
412 None,
413 CfgOptions::default(),
414 Env::default(),
415 Default::default(),
416 Default::default(),
417 );
418 let crate2 = graph.add_crate_root(
419 FileId(2u32),
420 Edition2018,
421 None,
422 CfgOptions::default(),
423 Env::default(),
424 Default::default(),
425 Default::default(),
426 );
427 assert!(graph.add_dep(crate1, CrateName::new("crate2").unwrap(), crate2).is_ok());
428 assert!(graph.add_dep(crate2, CrateName::new("crate2").unwrap(), crate2).is_err());
429 }
430
431 #[test]
407 fn it_works() { 432 fn it_works() {
408 let mut graph = CrateGraph::default(); 433 let mut graph = CrateGraph::default();
409 let crate1 = graph.add_crate_root( 434 let crate1 = graph.add_crate_root(
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 77baa4c69..b8f6aac8f 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -36,8 +36,8 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, mut def_map: CrateDefMap) -> Cr
36 36
37 // populate external prelude 37 // populate external prelude
38 for dep in &crate_graph[def_map.krate].dependencies { 38 for dep in &crate_graph[def_map.krate].dependencies {
39 let dep_def_map = db.crate_def_map(dep.crate_id);
40 log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); 39 log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id);
40 let dep_def_map = db.crate_def_map(dep.crate_id);
41 def_map.extern_prelude.insert( 41 def_map.extern_prelude.insert(
42 dep.as_name(), 42 dep.as_name(),
43 ModuleId { krate: dep.crate_id, local_id: dep_def_map.root }.into(), 43 ModuleId { krate: dep.crate_id, local_id: dep_def_map.root }.into(),
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts
index 492213937..f0b085420 100644
--- a/editors/code/src/net.ts
+++ b/editors/code/src/net.ts
@@ -124,8 +124,7 @@ async function downloadFile(
124 return new Promise<void>(resolve => { 124 return new Promise<void>(resolve => {
125 destFileStream.on("close", resolve); 125 destFileStream.on("close", resolve);
126 destFileStream.destroy(); 126 destFileStream.destroy();
127 127 // This workaround is awaiting to be removed when vscode moves to newer nodejs version:
128 // Details on workaround: https://github.com/rust-analyzer/rust-analyzer/pull/3092#discussion_r378191131 128 // https://github.com/rust-analyzer/rust-analyzer/issues/3167
129 // Issue at nodejs repo: https://github.com/nodejs/node/issues/31776
130 }); 129 });
131} 130}