aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock176
-rw-r--r--crates/hir/Cargo.toml (renamed from crates/ra_hir/Cargo.toml)11
-rw-r--r--crates/hir/src/code_model.rs (renamed from crates/ra_hir/src/code_model.rs)0
-rw-r--r--crates/hir/src/db.rs (renamed from crates/ra_hir/src/db.rs)0
-rw-r--r--crates/hir/src/diagnostics.rs (renamed from crates/ra_hir/src/diagnostics.rs)0
-rw-r--r--crates/hir/src/from_id.rs (renamed from crates/ra_hir/src/from_id.rs)0
-rw-r--r--crates/hir/src/has_source.rs (renamed from crates/ra_hir/src/has_source.rs)0
-rw-r--r--crates/hir/src/lib.rs (renamed from crates/ra_hir/src/lib.rs)4
-rw-r--r--crates/hir/src/semantics.rs (renamed from crates/ra_hir/src/semantics.rs)0
-rw-r--r--crates/hir/src/semantics/source_to_def.rs (renamed from crates/ra_hir/src/semantics/source_to_def.rs)0
-rw-r--r--crates/hir/src/source_analyzer.rs (renamed from crates/ra_hir/src/source_analyzer.rs)0
-rw-r--r--crates/hir_ty/Cargo.toml (renamed from crates/ra_hir_ty/Cargo.toml)23
-rw-r--r--crates/hir_ty/src/autoderef.rs (renamed from crates/ra_hir_ty/src/autoderef.rs)0
-rw-r--r--crates/hir_ty/src/db.rs (renamed from crates/ra_hir_ty/src/db.rs)0
-rw-r--r--crates/hir_ty/src/diagnostics.rs (renamed from crates/ra_hir_ty/src/diagnostics.rs)0
-rw-r--r--crates/hir_ty/src/diagnostics/expr.rs (renamed from crates/ra_hir_ty/src/diagnostics/expr.rs)0
-rw-r--r--crates/hir_ty/src/diagnostics/match_check.rs (renamed from crates/ra_hir_ty/src/diagnostics/match_check.rs)0
-rw-r--r--crates/hir_ty/src/diagnostics/unsafe_check.rs (renamed from crates/ra_hir_ty/src/diagnostics/unsafe_check.rs)0
-rw-r--r--crates/hir_ty/src/display.rs (renamed from crates/ra_hir_ty/src/display.rs)0
-rw-r--r--crates/hir_ty/src/infer.rs (renamed from crates/ra_hir_ty/src/infer.rs)0
-rw-r--r--crates/hir_ty/src/infer/coerce.rs (renamed from crates/ra_hir_ty/src/infer/coerce.rs)0
-rw-r--r--crates/hir_ty/src/infer/expr.rs (renamed from crates/ra_hir_ty/src/infer/expr.rs)0
-rw-r--r--crates/hir_ty/src/infer/pat.rs (renamed from crates/ra_hir_ty/src/infer/pat.rs)0
-rw-r--r--crates/hir_ty/src/infer/path.rs (renamed from crates/ra_hir_ty/src/infer/path.rs)0
-rw-r--r--crates/hir_ty/src/infer/unify.rs (renamed from crates/ra_hir_ty/src/infer/unify.rs)0
-rw-r--r--crates/hir_ty/src/lib.rs (renamed from crates/ra_hir_ty/src/lib.rs)0
-rw-r--r--crates/hir_ty/src/lower.rs (renamed from crates/ra_hir_ty/src/lower.rs)0
-rw-r--r--crates/hir_ty/src/method_resolution.rs (renamed from crates/ra_hir_ty/src/method_resolution.rs)0
-rw-r--r--crates/hir_ty/src/op.rs (renamed from crates/ra_hir_ty/src/op.rs)0
-rw-r--r--crates/hir_ty/src/primitive.rs (renamed from crates/ra_hir_ty/src/primitive.rs)0
-rw-r--r--crates/hir_ty/src/test_db.rs (renamed from crates/ra_hir_ty/src/test_db.rs)0
-rw-r--r--crates/hir_ty/src/tests.rs (renamed from crates/ra_hir_ty/src/tests.rs)2
-rw-r--r--crates/hir_ty/src/tests/coercion.rs (renamed from crates/ra_hir_ty/src/tests/coercion.rs)0
-rw-r--r--crates/hir_ty/src/tests/display_source_code.rs (renamed from crates/ra_hir_ty/src/tests/display_source_code.rs)0
-rw-r--r--crates/hir_ty/src/tests/macros.rs (renamed from crates/ra_hir_ty/src/tests/macros.rs)0
-rw-r--r--crates/hir_ty/src/tests/method_resolution.rs (renamed from crates/ra_hir_ty/src/tests/method_resolution.rs)0
-rw-r--r--crates/hir_ty/src/tests/never_type.rs (renamed from crates/ra_hir_ty/src/tests/never_type.rs)0
-rw-r--r--crates/hir_ty/src/tests/patterns.rs (renamed from crates/ra_hir_ty/src/tests/patterns.rs)0
-rw-r--r--crates/hir_ty/src/tests/regression.rs (renamed from crates/ra_hir_ty/src/tests/regression.rs)0
-rw-r--r--crates/hir_ty/src/tests/simple.rs (renamed from crates/ra_hir_ty/src/tests/simple.rs)0
-rw-r--r--crates/hir_ty/src/tests/traits.rs (renamed from crates/ra_hir_ty/src/tests/traits.rs)0
-rw-r--r--crates/hir_ty/src/traits.rs (renamed from crates/ra_hir_ty/src/traits.rs)0
-rw-r--r--crates/hir_ty/src/traits/chalk.rs (renamed from crates/ra_hir_ty/src/traits/chalk.rs)0
-rw-r--r--crates/hir_ty/src/traits/chalk/interner.rs (renamed from crates/ra_hir_ty/src/traits/chalk/interner.rs)0
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs (renamed from crates/ra_hir_ty/src/traits/chalk/mapping.rs)0
-rw-r--r--crates/hir_ty/src/traits/chalk/tls.rs (renamed from crates/ra_hir_ty/src/traits/chalk/tls.rs)0
-rw-r--r--crates/hir_ty/src/utils.rs (renamed from crates/ra_hir_ty/src/utils.rs)0
-rw-r--r--crates/ide_db/Cargo.toml (renamed from crates/ra_ide_db/Cargo.toml)12
-rw-r--r--crates/ide_db/src/change.rs (renamed from crates/ra_ide_db/src/change.rs)0
-rw-r--r--crates/ide_db/src/defs.rs (renamed from crates/ra_ide_db/src/defs.rs)0
-rw-r--r--crates/ide_db/src/imports_locator.rs (renamed from crates/ra_ide_db/src/imports_locator.rs)0
-rw-r--r--crates/ide_db/src/lib.rs (renamed from crates/ra_ide_db/src/lib.rs)0
-rw-r--r--crates/ide_db/src/line_index.rs (renamed from crates/ra_ide_db/src/line_index.rs)0
-rw-r--r--crates/ide_db/src/search.rs (renamed from crates/ra_ide_db/src/search.rs)0
-rw-r--r--crates/ide_db/src/source_change.rs (renamed from crates/ra_ide_db/src/source_change.rs)0
-rw-r--r--crates/ide_db/src/symbol_index.rs (renamed from crates/ra_ide_db/src/symbol_index.rs)0
-rw-r--r--crates/ide_db/src/wasm_shims.rs (renamed from crates/ra_ide_db/src/wasm_shims.rs)0
-rw-r--r--crates/ra_assists/Cargo.toml4
-rw-r--r--crates/ra_assists/src/assist_context.rs2
-rw-r--r--crates/ra_assists/src/handlers/add_turbo_fish.rs2
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs2
-rw-r--r--crates/ra_assists/src/handlers/expand_glob_import.rs2
-rw-r--r--crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs2
-rw-r--r--crates/ra_assists/src/handlers/fill_match_arms.rs2
-rw-r--r--crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs2
-rw-r--r--crates/ra_assists/src/handlers/inline_local_variable.rs2
-rw-r--r--crates/ra_assists/src/handlers/reorder_fields.rs2
-rw-r--r--crates/ra_assists/src/lib.rs2
-rw-r--r--crates/ra_assists/src/tests.rs2
-rw-r--r--crates/ra_assists/src/utils.rs2
-rw-r--r--crates/ra_ide/Cargo.toml6
-rw-r--r--crates/ra_ide/src/call_hierarchy.rs2
-rw-r--r--crates/ra_ide/src/call_info.rs2
-rw-r--r--crates/ra_ide/src/completion.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs2
-rw-r--r--crates/ra_ide/src/diagnostics.rs2
-rw-r--r--crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs2
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs2
-rw-r--r--crates/ra_ide/src/expand_macro.rs2
-rw-r--r--crates/ra_ide/src/extend_selection.rs2
-rw-r--r--crates/ra_ide/src/goto_definition.rs2
-rw-r--r--crates/ra_ide/src/goto_implementation.rs2
-rw-r--r--crates/ra_ide/src/goto_type_definition.rs2
-rw-r--r--crates/ra_ide/src/hover.rs4
-rw-r--r--crates/ra_ide/src/inlay_hints.rs2
-rw-r--r--crates/ra_ide/src/lib.rs26
-rw-r--r--crates/ra_ide/src/parent_module.rs2
-rw-r--r--crates/ra_ide/src/references.rs4
-rw-r--r--crates/ra_ide/src/references/rename.rs2
-rw-r--r--crates/ra_ide/src/runnables.rs2
-rw-r--r--crates/ra_ide/src/ssr.rs72
-rw-r--r--crates/ra_ide/src/status.rs4
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs2
-rw-r--r--crates/ra_ide/src/syntax_tree.rs2
-rw-r--r--crates/ra_ide/src/typing.rs2
-rw-r--r--crates/ra_ide/src/typing/on_enter.rs2
-rw-r--r--crates/rust-analyzer/Cargo.toml8
-rw-r--r--crates/rust-analyzer/src/bin/args.rs2
-rw-r--r--crates/rust-analyzer/src/cli.rs12
-rw-r--r--crates/rust-analyzer/src/cli/ssr.rs4
-rw-r--r--crates/ssr/Cargo.toml (renamed from crates/ra_ssr/Cargo.toml)15
-rw-r--r--crates/ssr/src/errors.rs (renamed from crates/ra_ssr/src/errors.rs)0
-rw-r--r--crates/ssr/src/lib.rs (renamed from crates/ra_ssr/src/lib.rs)62
-rw-r--r--crates/ssr/src/matching.rs (renamed from crates/ra_ssr/src/matching.rs)8
-rw-r--r--crates/ssr/src/nester.rs (renamed from crates/ra_ssr/src/nester.rs)10
-rw-r--r--crates/ssr/src/parsing.rs (renamed from crates/ra_ssr/src/parsing.rs)0
-rw-r--r--crates/ssr/src/replacing.rs (renamed from crates/ra_ssr/src/replacing.rs)0
-rw-r--r--crates/ssr/src/resolving.rs (renamed from crates/ra_ssr/src/resolving.rs)2
-rw-r--r--crates/ssr/src/search.rs (renamed from crates/ra_ssr/src/search.rs)4
-rw-r--r--crates/ssr/src/tests.rs (renamed from crates/ra_ssr/src/tests.rs)8
-rw-r--r--docs/dev/README.md6
-rw-r--r--docs/dev/architecture.md6
-rw-r--r--docs/dev/guide.md38
-rw-r--r--xtask/tests/tidy.rs4
114 files changed, 288 insertions, 313 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 702bd5191..4d8b74839 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -464,6 +464,24 @@ dependencies = [
464] 464]
465 465
466[[package]] 466[[package]]
467name = "hir"
468version = "0.0.0"
469dependencies = [
470 "arrayvec",
471 "base_db",
472 "either",
473 "hir_def",
474 "hir_expand",
475 "hir_ty",
476 "itertools",
477 "log",
478 "profile",
479 "rustc-hash",
480 "stdx",
481 "syntax",
482]
483
484[[package]]
467name = "hir_def" 485name = "hir_def"
468version = "0.0.0" 486version = "0.0.0"
469dependencies = [ 487dependencies = [
@@ -508,6 +526,34 @@ dependencies = [
508] 526]
509 527
510[[package]] 528[[package]]
529name = "hir_ty"
530version = "0.0.0"
531dependencies = [
532 "arena",
533 "arrayvec",
534 "base_db",
535 "chalk-ir",
536 "chalk-recursive",
537 "chalk-solve",
538 "ena",
539 "expect",
540 "hir_def",
541 "hir_expand",
542 "itertools",
543 "log",
544 "profile",
545 "rustc-hash",
546 "scoped-tls",
547 "smallvec",
548 "stdx",
549 "syntax",
550 "test_utils",
551 "tracing",
552 "tracing-subscriber",
553 "tracing-tree",
554]
555
556[[package]]
511name = "home" 557name = "home"
512version = "0.5.3" 558version = "0.5.3"
513source = "registry+https://github.com/rust-lang/crates.io-index" 559source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -517,6 +563,25 @@ dependencies = [
517] 563]
518 564
519[[package]] 565[[package]]
566name = "ide_db"
567version = "0.0.0"
568dependencies = [
569 "base_db",
570 "either",
571 "fst",
572 "hir",
573 "log",
574 "once_cell",
575 "profile",
576 "rayon",
577 "rustc-hash",
578 "stdx",
579 "syntax",
580 "test_utils",
581 "text_edit",
582]
583
584[[package]]
520name = "idna" 585name = "idna"
521version = "0.2.0" 586version = "0.2.0"
522source = "registry+https://github.com/rust-lang/crates.io-index" 587source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1043,10 +1108,10 @@ version = "0.1.0"
1043dependencies = [ 1108dependencies = [
1044 "base_db", 1109 "base_db",
1045 "either", 1110 "either",
1111 "hir",
1112 "ide_db",
1046 "itertools", 1113 "itertools",
1047 "profile", 1114 "profile",
1048 "ra_hir",
1049 "ra_ide_db",
1050 "rustc-hash", 1115 "rustc-hash",
1051 "stdx", 1116 "stdx",
1052 "syntax", 1117 "syntax",
@@ -1055,52 +1120,6 @@ dependencies = [
1055] 1120]
1056 1121
1057[[package]] 1122[[package]]
1058name = "ra_hir"
1059version = "0.1.0"
1060dependencies = [
1061 "arrayvec",
1062 "base_db",
1063 "either",
1064 "hir_def",
1065 "hir_expand",
1066 "itertools",
1067 "log",
1068 "profile",
1069 "ra_hir_ty",
1070 "rustc-hash",
1071 "stdx",
1072 "syntax",
1073]
1074
1075[[package]]
1076name = "ra_hir_ty"
1077version = "0.1.0"
1078dependencies = [
1079 "arena",
1080 "arrayvec",
1081 "base_db",
1082 "chalk-ir",
1083 "chalk-recursive",
1084 "chalk-solve",
1085 "ena",
1086 "expect",
1087 "hir_def",
1088 "hir_expand",
1089 "itertools",
1090 "log",
1091 "profile",
1092 "rustc-hash",
1093 "scoped-tls",
1094 "smallvec",
1095 "stdx",
1096 "syntax",
1097 "test_utils",
1098 "tracing",
1099 "tracing-subscriber",
1100 "tracing-tree",
1101]
1102
1103[[package]]
1104name = "ra_ide" 1123name = "ra_ide"
1105version = "0.1.0" 1124version = "0.1.0"
1106dependencies = [ 1125dependencies = [
@@ -1108,16 +1127,16 @@ dependencies = [
1108 "cfg", 1127 "cfg",
1109 "either", 1128 "either",
1110 "expect", 1129 "expect",
1130 "hir",
1131 "ide_db",
1111 "indexmap", 1132 "indexmap",
1112 "itertools", 1133 "itertools",
1113 "log", 1134 "log",
1114 "oorandom", 1135 "oorandom",
1115 "profile", 1136 "profile",
1116 "ra_assists", 1137 "ra_assists",
1117 "ra_hir",
1118 "ra_ide_db",
1119 "ra_ssr",
1120 "rustc-hash", 1138 "rustc-hash",
1139 "ssr",
1121 "stdx", 1140 "stdx",
1122 "syntax", 1141 "syntax",
1123 "test_utils", 1142 "test_utils",
@@ -1125,39 +1144,6 @@ dependencies = [
1125] 1144]
1126 1145
1127[[package]] 1146[[package]]
1128name = "ra_ide_db"
1129version = "0.1.0"
1130dependencies = [
1131 "base_db",
1132 "either",
1133 "fst",
1134 "log",
1135 "once_cell",
1136 "profile",
1137 "ra_hir",
1138 "rayon",
1139 "rustc-hash",
1140 "stdx",
1141 "syntax",
1142 "test_utils",
1143 "text_edit",
1144]
1145
1146[[package]]
1147name = "ra_ssr"
1148version = "0.1.0"
1149dependencies = [
1150 "base_db",
1151 "expect",
1152 "ra_hir",
1153 "ra_ide_db",
1154 "rustc-hash",
1155 "syntax",
1156 "test_utils",
1157 "text_edit",
1158]
1159
1160[[package]]
1161name = "rayon" 1147name = "rayon"
1162version = "1.3.1" 1148version = "1.3.1"
1163source = "registry+https://github.com/rust-lang/crates.io-index" 1149source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1236,7 +1222,10 @@ dependencies = [
1236 "env_logger", 1222 "env_logger",
1237 "expect", 1223 "expect",
1238 "flycheck", 1224 "flycheck",
1225 "hir",
1239 "hir_def", 1226 "hir_def",
1227 "hir_ty",
1228 "ide_db",
1240 "itertools", 1229 "itertools",
1241 "jod-thread", 1230 "jod-thread",
1242 "log", 1231 "log",
@@ -1250,15 +1239,12 @@ dependencies = [
1250 "proc_macro_srv", 1239 "proc_macro_srv",
1251 "profile", 1240 "profile",
1252 "project_model", 1241 "project_model",
1253 "ra_hir",
1254 "ra_hir_ty",
1255 "ra_ide", 1242 "ra_ide",
1256 "ra_ide_db",
1257 "ra_ssr",
1258 "rayon", 1243 "rayon",
1259 "rustc-hash", 1244 "rustc-hash",
1260 "serde", 1245 "serde",
1261 "serde_json", 1246 "serde_json",
1247 "ssr",
1262 "stdx", 1248 "stdx",
1263 "syntax", 1249 "syntax",
1264 "test_utils", 1250 "test_utils",
@@ -1457,6 +1443,20 @@ dependencies = [
1457] 1443]
1458 1444
1459[[package]] 1445[[package]]
1446name = "ssr"
1447version = "0.1.0"
1448dependencies = [
1449 "base_db",
1450 "expect",
1451 "hir",
1452 "ide_db",
1453 "rustc-hash",
1454 "syntax",
1455 "test_utils",
1456 "text_edit",
1457]
1458
1459[[package]]
1460name = "stdx" 1460name = "stdx"
1461version = "0.1.0" 1461version = "0.1.0"
1462 1462
diff --git a/crates/ra_hir/Cargo.toml b/crates/hir/Cargo.toml
index edca5dc6f..dbb2986b6 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/hir/Cargo.toml
@@ -1,9 +1,9 @@
1[package] 1[package]
2edition = "2018" 2name = "hir"
3name = "ra_hir" 3version = "0.0.0"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6license = "MIT OR Apache-2.0" 4license = "MIT OR Apache-2.0"
5authors = ["rust-analyzer developers"]
6edition = "2018"
7 7
8[lib] 8[lib]
9doctest = false 9doctest = false
@@ -13,7 +13,6 @@ log = "0.4.8"
13rustc-hash = "1.1.0" 13rustc-hash = "1.1.0"
14either = "1.5.3" 14either = "1.5.3"
15arrayvec = "0.5.1" 15arrayvec = "0.5.1"
16
17itertools = "0.9.0" 16itertools = "0.9.0"
18 17
19stdx = { path = "../stdx" } 18stdx = { path = "../stdx" }
@@ -22,4 +21,4 @@ base_db = { path = "../base_db" }
22profile = { path = "../profile" } 21profile = { path = "../profile" }
23hir_expand = { path = "../hir_expand" } 22hir_expand = { path = "../hir_expand" }
24hir_def = { path = "../hir_def" } 23hir_def = { path = "../hir_def" }
25hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } 24hir_ty = { path = "../hir_ty" }
diff --git a/crates/ra_hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 8ffb9e99b..8ffb9e99b 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
diff --git a/crates/ra_hir/src/db.rs b/crates/hir/src/db.rs
index 07333c453..07333c453 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/hir/src/db.rs
diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs
index 363164b9b..363164b9b 100644
--- a/crates/ra_hir/src/diagnostics.rs
+++ b/crates/hir/src/diagnostics.rs
diff --git a/crates/ra_hir/src/from_id.rs b/crates/hir/src/from_id.rs
index a53ac1e08..a53ac1e08 100644
--- a/crates/ra_hir/src/from_id.rs
+++ b/crates/hir/src/from_id.rs
diff --git a/crates/ra_hir/src/has_source.rs b/crates/hir/src/has_source.rs
index a50d4ff02..a50d4ff02 100644
--- a/crates/ra_hir/src/has_source.rs
+++ b/crates/hir/src/has_source.rs
diff --git a/crates/ra_hir/src/lib.rs b/crates/hir/src/lib.rs
index 34b02c536..24a0f6b4b 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -9,11 +9,11 @@
9//! It is written in "OO" style. Each type is self contained (as in, it knows it's 9//! It is written in "OO" style. Each type is self contained (as in, it knows it's
10//! parents and full context). It should be "clean code". 10//! parents and full context). It should be "clean code".
11//! 11//!
12//! `ra_hir_*` crates are the implementation of the compiler logic. 12//! `hir_*` crates are the implementation of the compiler logic.
13//! They are written in "ECS" style, with relatively little abstractions. 13//! They are written in "ECS" style, with relatively little abstractions.
14//! Many types are not self-contained, and explicitly use local indexes, arenas, etc. 14//! Many types are not self-contained, and explicitly use local indexes, arenas, etc.
15//! 15//!
16//! `ra_hir` is what insulates the "we don't know how to actually write an incremental compiler" 16//! `hir` is what insulates the "we don't know how to actually write an incremental compiler"
17//! from the ide with completions, hovers, etc. It is a (soft, internal) boundary: 17//! from the ide with completions, hovers, etc. It is a (soft, internal) boundary:
18//! https://www.tedinski.com/2018/02/06/system-boundaries.html. 18//! https://www.tedinski.com/2018/02/06/system-boundaries.html.
19 19
diff --git a/crates/ra_hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 1467d825d..1467d825d 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index 5918b9541..5918b9541 100644
--- a/crates/ra_hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 8750584f9..8750584f9 100644
--- a/crates/ra_hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml
index d430b08ca..83b5013a9 100644
--- a/crates/ra_hir_ty/Cargo.toml
+++ b/crates/hir_ty/Cargo.toml
@@ -1,9 +1,9 @@
1[package] 1[package]
2edition = "2018" 2name = "hir_ty"
3name = "ra_hir_ty" 3version = "0.0.0"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6license = "MIT OR Apache-2.0" 4license = "MIT OR Apache-2.0"
5authors = ["rust-analyzer developers"]
6edition = "2018"
7 7
8[lib] 8[lib]
9doctest = false 9doctest = false
@@ -15,9 +15,12 @@ smallvec = "1.2.0"
15ena = "0.14.0" 15ena = "0.14.0"
16log = "0.4.8" 16log = "0.4.8"
17rustc-hash = "1.1.0" 17rustc-hash = "1.1.0"
18scoped-tls = "1"
19chalk-solve = { version = "0.21.0" }
20chalk-ir = { version = "0.21.0" }
21chalk-recursive = { version = "0.21.0" }
18 22
19stdx = { path = "../stdx" } 23stdx = { path = "../stdx" }
20
21hir_def = { path = "../hir_def" } 24hir_def = { path = "../hir_def" }
22hir_expand = { path = "../hir_expand" } 25hir_expand = { path = "../hir_expand" }
23arena = { path = "../arena" } 26arena = { path = "../arena" }
@@ -26,15 +29,9 @@ profile = { path = "../profile" }
26syntax = { path = "../syntax" } 29syntax = { path = "../syntax" }
27test_utils = { path = "../test_utils" } 30test_utils = { path = "../test_utils" }
28 31
29scoped-tls = "1"
30
31chalk-solve = { version = "0.21.0" }
32chalk-ir = { version = "0.21.0" }
33chalk-recursive = { version = "0.21.0" }
34
35[dev-dependencies] 32[dev-dependencies]
36expect = { path = "../expect" }
37
38tracing = "0.1" 33tracing = "0.1"
39tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } 34tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] }
40tracing-tree = { version = "0.1.4" } 35tracing-tree = { version = "0.1.4" }
36
37expect = { path = "../expect" }
diff --git a/crates/ra_hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs
index ece68183e..ece68183e 100644
--- a/crates/ra_hir_ty/src/autoderef.rs
+++ b/crates/hir_ty/src/autoderef.rs
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/hir_ty/src/db.rs
index 25cf9eb7f..25cf9eb7f 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/hir_ty/src/db.rs
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs
index ae0cf8d09..ae0cf8d09 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/hir_ty/src/diagnostics.rs
diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs
index fb76e2e4e..fb76e2e4e 100644
--- a/crates/ra_hir_ty/src/diagnostics/expr.rs
+++ b/crates/hir_ty/src/diagnostics/expr.rs
diff --git a/crates/ra_hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs
index 7f007f1d6..7f007f1d6 100644
--- a/crates/ra_hir_ty/src/diagnostics/match_check.rs
+++ b/crates/hir_ty/src/diagnostics/match_check.rs
diff --git a/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs
index 61ffbf5d1..61ffbf5d1 100644
--- a/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs
+++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs
diff --git a/crates/ra_hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 19770e609..19770e609 100644
--- a/crates/ra_hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs
index 03b00b101..03b00b101 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/hir_ty/src/infer.rs
diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs
index 32c7c57cd..32c7c57cd 100644
--- a/crates/ra_hir_ty/src/infer/coerce.rs
+++ b/crates/hir_ty/src/infer/coerce.rs
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index a2f849d02..a2f849d02 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs
index 4dd4f9802..4dd4f9802 100644
--- a/crates/ra_hir_ty/src/infer/pat.rs
+++ b/crates/hir_ty/src/infer/pat.rs
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs
index 80d7ed10e..80d7ed10e 100644
--- a/crates/ra_hir_ty/src/infer/path.rs
+++ b/crates/hir_ty/src/infer/path.rs
diff --git a/crates/ra_hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs
index 2e895d911..2e895d911 100644
--- a/crates/ra_hir_ty/src/infer/unify.rs
+++ b/crates/hir_ty/src/infer/unify.rs
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 1e748476a..1e748476a 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index cd574e983..cd574e983 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index ec59145c7..ec59145c7 100644
--- a/crates/ra_hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
diff --git a/crates/ra_hir_ty/src/op.rs b/crates/hir_ty/src/op.rs
index 0870874fc..0870874fc 100644
--- a/crates/ra_hir_ty/src/op.rs
+++ b/crates/hir_ty/src/op.rs
diff --git a/crates/ra_hir_ty/src/primitive.rs b/crates/hir_ty/src/primitive.rs
index 37966b709..37966b709 100644
--- a/crates/ra_hir_ty/src/primitive.rs
+++ b/crates/hir_ty/src/primitive.rs
diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/hir_ty/src/test_db.rs
index 15b8435e9..15b8435e9 100644
--- a/crates/ra_hir_ty/src/test_db.rs
+++ b/crates/hir_ty/src/test_db.rs
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs
index f6b172c3a..c953925ec 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/hir_ty/src/tests.rs
@@ -35,7 +35,7 @@ use crate::{
35 35
36// These tests compare the inference results for all expressions in a file 36// These tests compare the inference results for all expressions in a file
37// against snapshots of the expected results using expect. Use 37// against snapshots of the expected results using expect. Use
38// `env UPDATE_EXPECT=1 cargo test -p ra_hir_ty` to update the snapshots. 38// `env UPDATE_EXPECT=1 cargo test -p hir_ty` to update the snapshots.
39 39
40fn setup_tracing() -> tracing::subscriber::DefaultGuard { 40fn setup_tracing() -> tracing::subscriber::DefaultGuard {
41 use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; 41 use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs
index 17efd75cb..17efd75cb 100644
--- a/crates/ra_hir_ty/src/tests/coercion.rs
+++ b/crates/hir_ty/src/tests/coercion.rs
diff --git a/crates/ra_hir_ty/src/tests/display_source_code.rs b/crates/hir_ty/src/tests/display_source_code.rs
index b502135d8..b502135d8 100644
--- a/crates/ra_hir_ty/src/tests/display_source_code.rs
+++ b/crates/hir_ty/src/tests/display_source_code.rs
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs
index d887c7a79..d887c7a79 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/hir_ty/src/tests/macros.rs
diff --git a/crates/ra_hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs
index fa68355aa..fa68355aa 100644
--- a/crates/ra_hir_ty/src/tests/method_resolution.rs
+++ b/crates/hir_ty/src/tests/method_resolution.rs
diff --git a/crates/ra_hir_ty/src/tests/never_type.rs b/crates/hir_ty/src/tests/never_type.rs
index 49538b572..49538b572 100644
--- a/crates/ra_hir_ty/src/tests/never_type.rs
+++ b/crates/hir_ty/src/tests/never_type.rs
diff --git a/crates/ra_hir_ty/src/tests/patterns.rs b/crates/hir_ty/src/tests/patterns.rs
index 39fabf7eb..39fabf7eb 100644
--- a/crates/ra_hir_ty/src/tests/patterns.rs
+++ b/crates/hir_ty/src/tests/patterns.rs
diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs
index b9ab0f357..b9ab0f357 100644
--- a/crates/ra_hir_ty/src/tests/regression.rs
+++ b/crates/hir_ty/src/tests/regression.rs
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs
index 59eb59d5f..59eb59d5f 100644
--- a/crates/ra_hir_ty/src/tests/simple.rs
+++ b/crates/hir_ty/src/tests/simple.rs
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index 526e61caf..526e61caf 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs
index 255323717..255323717 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/hir_ty/src/traits.rs
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index b33653417..b33653417 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs
index fc0f9c201..fc0f9c201 100644
--- a/crates/ra_hir_ty/src/traits/chalk/interner.rs
+++ b/crates/hir_ty/src/traits/chalk/interner.rs
diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index fe62f3fa7..fe62f3fa7 100644
--- a/crates/ra_hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/hir_ty/src/traits/chalk/tls.rs
index db915625c..db915625c 100644
--- a/crates/ra_hir_ty/src/traits/chalk/tls.rs
+++ b/crates/hir_ty/src/traits/chalk/tls.rs
diff --git a/crates/ra_hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs
index e3e244268..e3e244268 100644
--- a/crates/ra_hir_ty/src/utils.rs
+++ b/crates/hir_ty/src/utils.rs
diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ide_db/Cargo.toml
index 0cda7090d..885212162 100644
--- a/crates/ra_ide_db/Cargo.toml
+++ b/crates/ide_db/Cargo.toml
@@ -1,9 +1,9 @@
1[package] 1[package]
2edition = "2018" 2name = "ide_db"
3name = "ra_ide_db" 3version = "0.0.0"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6license = "MIT OR Apache-2.0" 4license = "MIT OR Apache-2.0"
5authors = ["rust-analyzer developers"]
6edition = "2018"
7 7
8[lib] 8[lib]
9doctest = false 9doctest = false
@@ -20,13 +20,11 @@ once_cell = "1.3.1"
20either = "1.5.3" 20either = "1.5.3"
21 21
22stdx = { path = "../stdx" } 22stdx = { path = "../stdx" }
23
24syntax = { path = "../syntax" } 23syntax = { path = "../syntax" }
25text_edit = { path = "../text_edit" } 24text_edit = { path = "../text_edit" }
26base_db = { path = "../base_db" } 25base_db = { path = "../base_db" }
27profile = { path = "../profile" } 26profile = { path = "../profile" }
28test_utils = { path = "../test_utils" } 27test_utils = { path = "../test_utils" }
29
30# ra_ide should depend only on the top-level `hir` package. if you need 28# ra_ide should depend only on the top-level `hir` package. if you need
31# something from some `hir_xxx` subpackage, reexport the API via `hir`. 29# something from some `hir_xxx` subpackage, reexport the API via `hir`.
32hir = { path = "../ra_hir", package = "ra_hir" } 30hir = { path = "../hir" }
diff --git a/crates/ra_ide_db/src/change.rs b/crates/ide_db/src/change.rs
index 8b4fd7ab8..8b4fd7ab8 100644
--- a/crates/ra_ide_db/src/change.rs
+++ b/crates/ide_db/src/change.rs
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ide_db/src/defs.rs
index 7b5d6ac49..7b5d6ac49 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ide_db/src/defs.rs
diff --git a/crates/ra_ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs
index 1d0c20291..1d0c20291 100644
--- a/crates/ra_ide_db/src/imports_locator.rs
+++ b/crates/ide_db/src/imports_locator.rs
diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ide_db/src/lib.rs
index fd474cd0f..fd474cd0f 100644
--- a/crates/ra_ide_db/src/lib.rs
+++ b/crates/ide_db/src/lib.rs
diff --git a/crates/ra_ide_db/src/line_index.rs b/crates/ide_db/src/line_index.rs
index a381f7fb8..a381f7fb8 100644
--- a/crates/ra_ide_db/src/line_index.rs
+++ b/crates/ide_db/src/line_index.rs
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ide_db/src/search.rs
index b9360bf12..b9360bf12 100644
--- a/crates/ra_ide_db/src/search.rs
+++ b/crates/ide_db/src/search.rs
diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ide_db/src/source_change.rs
index f1590ec66..f1590ec66 100644
--- a/crates/ra_ide_db/src/source_change.rs
+++ b/crates/ide_db/src/source_change.rs
diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs
index 654df898e..654df898e 100644
--- a/crates/ra_ide_db/src/symbol_index.rs
+++ b/crates/ide_db/src/symbol_index.rs
diff --git a/crates/ra_ide_db/src/wasm_shims.rs b/crates/ide_db/src/wasm_shims.rs
index 7af9f9d9b..7af9f9d9b 100644
--- a/crates/ra_ide_db/src/wasm_shims.rs
+++ b/crates/ide_db/src/wasm_shims.rs
diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml
index ebac09be6..19e7591f7 100644
--- a/crates/ra_assists/Cargo.toml
+++ b/crates/ra_assists/Cargo.toml
@@ -19,6 +19,6 @@ syntax = { path = "../syntax" }
19text_edit = { path = "../text_edit" } 19text_edit = { path = "../text_edit" }
20profile = { path = "../profile" } 20profile = { path = "../profile" }
21base_db = { path = "../base_db" } 21base_db = { path = "../base_db" }
22ra_ide_db = { path = "../ra_ide_db" } 22ide_db = { path = "../ide_db" }
23hir = { path = "../ra_hir", package = "ra_hir" } 23hir = { path = "../hir" }
24test_utils = { path = "../test_utils" } 24test_utils = { path = "../test_utils" }
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs
index 2fdce037f..79574b9ac 100644
--- a/crates/ra_assists/src/assist_context.rs
+++ b/crates/ra_assists/src/assist_context.rs
@@ -5,7 +5,7 @@ use std::mem;
5use algo::find_covering_element; 5use algo::find_covering_element;
6use base_db::{FileId, FileRange}; 6use base_db::{FileId, FileRange};
7use hir::Semantics; 7use hir::Semantics;
8use ra_ide_db::{ 8use ide_db::{
9 source_change::{SourceChange, SourceFileEdit}, 9 source_change::{SourceChange, SourceFileEdit},
10 RootDatabase, 10 RootDatabase,
11}; 11};
diff --git a/crates/ra_assists/src/handlers/add_turbo_fish.rs b/crates/ra_assists/src/handlers/add_turbo_fish.rs
index 8c7ffae3d..f4f997d8e 100644
--- a/crates/ra_assists/src/handlers/add_turbo_fish.rs
+++ b/crates/ra_assists/src/handlers/add_turbo_fish.rs
@@ -1,4 +1,4 @@
1use ra_ide_db::defs::{classify_name_ref, Definition, NameRefClass}; 1use ide_db::defs::{classify_name_ref, Definition, NameRefClass};
2use syntax::{ast, AstNode, SyntaxKind, T}; 2use syntax::{ast, AstNode, SyntaxKind, T};
3use test_utils::mark; 3use test_utils::mark;
4 4
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs
index e19b197d9..cce789972 100644
--- a/crates/ra_assists/src/handlers/auto_import.rs
+++ b/crates/ra_assists/src/handlers/auto_import.rs
@@ -5,7 +5,7 @@ use hir::{
5 AsAssocItem, AssocItemContainer, ModPath, Module, ModuleDef, PathResolution, Semantics, Trait, 5 AsAssocItem, AssocItemContainer, ModPath, Module, ModuleDef, PathResolution, Semantics, Trait,
6 Type, 6 Type,
7}; 7};
8use ra_ide_db::{imports_locator, RootDatabase}; 8use ide_db::{imports_locator, RootDatabase};
9use rustc_hash::FxHashSet; 9use rustc_hash::FxHashSet;
10use syntax::{ 10use syntax::{
11 ast::{self, AstNode}, 11 ast::{self, AstNode},
diff --git a/crates/ra_assists/src/handlers/expand_glob_import.rs b/crates/ra_assists/src/handlers/expand_glob_import.rs
index cf34ffaf7..f690ec343 100644
--- a/crates/ra_assists/src/handlers/expand_glob_import.rs
+++ b/crates/ra_assists/src/handlers/expand_glob_import.rs
@@ -1,5 +1,5 @@
1use hir::{AssocItem, MacroDef, ModuleDef, Name, PathResolution, ScopeDef, SemanticsScope}; 1use hir::{AssocItem, MacroDef, ModuleDef, Name, PathResolution, ScopeDef, SemanticsScope};
2use ra_ide_db::{ 2use ide_db::{
3 defs::{classify_name_ref, Definition, NameRefClass}, 3 defs::{classify_name_ref, Definition, NameRefClass},
4 RootDatabase, 4 RootDatabase,
5}; 5};
diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
index 52fbc540e..4bcdae7ba 100644
--- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -1,6 +1,6 @@
1use base_db::FileId; 1use base_db::FileId;
2use hir::{EnumVariant, Module, ModuleDef, Name}; 2use hir::{EnumVariant, Module, ModuleDef, Name};
3use ra_ide_db::{defs::Definition, search::Reference, RootDatabase}; 3use ide_db::{defs::Definition, search::Reference, RootDatabase};
4use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
5use syntax::{ 5use syntax::{
6 algo::find_node_at_offset, 6 algo::find_node_at_offset,
diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs
index 8f6660637..3d9bdb2bf 100644
--- a/crates/ra_assists/src/handlers/fill_match_arms.rs
+++ b/crates/ra_assists/src/handlers/fill_match_arms.rs
@@ -1,8 +1,8 @@
1use std::iter; 1use std::iter;
2 2
3use hir::{Adt, HasSource, ModuleDef, Semantics}; 3use hir::{Adt, HasSource, ModuleDef, Semantics};
4use ide_db::RootDatabase;
4use itertools::Itertools; 5use itertools::Itertools;
5use ra_ide_db::RootDatabase;
6use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; 6use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
7use test_utils::mark; 7use test_utils::mark;
8 8
diff --git a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
index 302b6b67d..7f04b9572 100644
--- a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
+++ b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs
@@ -1,4 +1,4 @@
1use ra_ide_db::RootDatabase; 1use ide_db::RootDatabase;
2use syntax::ast::{self, AstNode, NameOwner}; 2use syntax::ast::{self, AstNode, NameOwner};
3use test_utils::mark; 3use test_utils::mark;
4 4
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs
index 531592320..2b52b333b 100644
--- a/crates/ra_assists/src/handlers/inline_local_variable.rs
+++ b/crates/ra_assists/src/handlers/inline_local_variable.rs
@@ -1,4 +1,4 @@
1use ra_ide_db::defs::Definition; 1use ide_db::defs::Definition;
2use syntax::{ 2use syntax::{
3 ast::{self, AstNode, AstToken}, 3 ast::{self, AstNode, AstToken},
4 TextRange, 4 TextRange,
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs
index 013720dfc..527f457a7 100644
--- a/crates/ra_assists/src/handlers/reorder_fields.rs
+++ b/crates/ra_assists/src/handlers/reorder_fields.rs
@@ -2,7 +2,7 @@ use itertools::Itertools;
2use rustc_hash::FxHashMap; 2use rustc_hash::FxHashMap;
3 3
4use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct}; 4use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct};
5use ra_ide_db::RootDatabase; 5use ide_db::RootDatabase;
6use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; 6use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode};
7 7
8use crate::{AssistContext, AssistId, AssistKind, Assists}; 8use crate::{AssistContext, AssistId, AssistKind, Assists};
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 5d062b88b..f0cf35caf 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -19,7 +19,7 @@ pub mod ast_transform;
19 19
20use base_db::FileRange; 20use base_db::FileRange;
21use hir::Semantics; 21use hir::Semantics;
22use ra_ide_db::{source_change::SourceChange, RootDatabase}; 22use ide_db::{source_change::SourceChange, RootDatabase};
23use syntax::TextRange; 23use syntax::TextRange;
24 24
25pub(crate) use crate::assist_context::{AssistContext, Assists}; 25pub(crate) use crate::assist_context::{AssistContext, Assists};
diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs
index 75d973688..ba1fb543b 100644
--- a/crates/ra_assists/src/tests.rs
+++ b/crates/ra_assists/src/tests.rs
@@ -2,7 +2,7 @@ mod generated;
2 2
3use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; 3use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt};
4use hir::Semantics; 4use hir::Semantics;
5use ra_ide_db::RootDatabase; 5use ide_db::RootDatabase;
6use syntax::TextRange; 6use syntax::TextRange;
7use test_utils::{assert_eq_text, extract_offset, extract_range}; 7use test_utils::{assert_eq_text, extract_offset, extract_range};
8 8
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs
index a20453dd8..84ccacafe 100644
--- a/crates/ra_assists/src/utils.rs
+++ b/crates/ra_assists/src/utils.rs
@@ -4,8 +4,8 @@ pub(crate) mod insert_use;
4use std::{iter, ops}; 4use std::{iter, ops};
5 5
6use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type}; 6use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type};
7use ide_db::RootDatabase;
7use itertools::Itertools; 8use itertools::Itertools;
8use ra_ide_db::RootDatabase;
9use rustc_hash::FxHashSet; 9use rustc_hash::FxHashSet;
10use syntax::{ 10use syntax::{
11 ast::{self, make, NameOwner}, 11 ast::{self, make, NameOwner},
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml
index 1af51f3ae..8519e9cca 100644
--- a/crates/ra_ide/Cargo.toml
+++ b/crates/ra_ide/Cargo.toml
@@ -24,16 +24,16 @@ stdx = { path = "../stdx" }
24syntax = { path = "../syntax" } 24syntax = { path = "../syntax" }
25text_edit = { path = "../text_edit" } 25text_edit = { path = "../text_edit" }
26base_db = { path = "../base_db" } 26base_db = { path = "../base_db" }
27ra_ide_db = { path = "../ra_ide_db" } 27ide_db = { path = "../ide_db" }
28cfg = { path = "../cfg" } 28cfg = { path = "../cfg" }
29profile = { path = "../profile" } 29profile = { path = "../profile" }
30test_utils = { path = "../test_utils" } 30test_utils = { path = "../test_utils" }
31ra_assists = { path = "../ra_assists" } 31ra_assists = { path = "../ra_assists" }
32ra_ssr = { path = "../ra_ssr" } 32ssr = { path = "../ssr" }
33 33
34# ra_ide should depend only on the top-level `hir` package. if you need 34# ra_ide should depend only on the top-level `hir` package. if you need
35# something from some `hir_xxx` subpackage, reexport the API via `hir`. 35# something from some `hir_xxx` subpackage, reexport the API via `hir`.
36hir = { path = "../ra_hir", package = "ra_hir" } 36hir = { path = "../hir" }
37 37
38[dev-dependencies] 38[dev-dependencies]
39expect = { path = "../expect" } 39expect = { path = "../expect" }
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs
index 3578b8d3c..58e26b94c 100644
--- a/crates/ra_ide/src/call_hierarchy.rs
+++ b/crates/ra_ide/src/call_hierarchy.rs
@@ -3,7 +3,7 @@
3use indexmap::IndexMap; 3use indexmap::IndexMap;
4 4
5use hir::Semantics; 5use hir::Semantics;
6use ra_ide_db::RootDatabase; 6use ide_db::RootDatabase;
7use syntax::{ast, match_ast, AstNode, TextRange}; 7use syntax::{ast, match_ast, AstNode, TextRange};
8 8
9use crate::{ 9use crate::{
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs
index 703cbc6b4..86abd2d8c 100644
--- a/crates/ra_ide/src/call_info.rs
+++ b/crates/ra_ide/src/call_info.rs
@@ -1,7 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2use either::Either; 2use either::Either;
3use hir::{Docs, HirDisplay, Semantics, Type}; 3use hir::{Docs, HirDisplay, Semantics, Type};
4use ra_ide_db::RootDatabase; 4use ide_db::RootDatabase;
5use stdx::format_to; 5use stdx::format_to;
6use syntax::{ 6use syntax::{
7 ast::{self, ArgListOwner}, 7 ast::{self, ArgListOwner},
diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs
index 68ac05e4c..7fb4d687e 100644
--- a/crates/ra_ide/src/completion.rs
+++ b/crates/ra_ide/src/completion.rs
@@ -19,7 +19,7 @@ mod complete_postfix;
19mod complete_macro_in_item_position; 19mod complete_macro_in_item_position;
20mod complete_trait_impl; 20mod complete_trait_impl;
21 21
22use ra_ide_db::RootDatabase; 22use ide_db::RootDatabase;
23 23
24use crate::{ 24use crate::{
25 completion::{ 25 completion::{
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 0e0a201d0..047ecd9d7 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -2,7 +2,7 @@
2 2
3use base_db::SourceDatabase; 3use base_db::SourceDatabase;
4use hir::{Semantics, SemanticsScope, Type}; 4use hir::{Semantics, SemanticsScope, Type};
5use ra_ide_db::RootDatabase; 5use ide_db::RootDatabase;
6use syntax::{ 6use syntax::{
7 algo::{find_covering_element, find_node_at_offset}, 7 algo::{find_covering_element, find_node_at_offset},
8 ast, match_ast, AstNode, NodeOrToken, 8 ast, match_ast, AstNode, NodeOrToken,
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 4e59e3a48..a3ec98178 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -8,8 +8,8 @@ use std::cell::RefCell;
8 8
9use base_db::SourceDatabase; 9use base_db::SourceDatabase;
10use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; 10use hir::{diagnostics::DiagnosticSinkBuilder, Semantics};
11use ide_db::RootDatabase;
11use itertools::Itertools; 12use itertools::Itertools;
12use ra_ide_db::RootDatabase;
13use syntax::{ 13use syntax::{
14 ast::{self, AstNode}, 14 ast::{self, AstNode},
15 SyntaxNode, TextRange, T, 15 SyntaxNode, TextRange, T,
diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs
index 7e126d7a6..85b46c995 100644
--- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs
+++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs
@@ -8,7 +8,7 @@ use hir::{
8 diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, 8 diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule},
9 HasSource, HirDisplay, Semantics, VariantDef, 9 HasSource, HirDisplay, Semantics, VariantDef,
10}; 10};
11use ra_ide_db::{ 11use ide_db::{
12 source_change::{FileSystemEdit, SourceFileEdit}, 12 source_change::{FileSystemEdit, SourceFileEdit},
13 RootDatabase, 13 RootDatabase,
14}; 14};
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs
index 09ec3f65e..e77106177 100644
--- a/crates/ra_ide/src/display/navigation_target.rs
+++ b/crates/ra_ide/src/display/navigation_target.rs
@@ -3,7 +3,7 @@
3use base_db::{FileId, SourceDatabase}; 3use base_db::{FileId, SourceDatabase};
4use either::Either; 4use either::Either;
5use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; 5use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource};
6use ra_ide_db::{defs::Definition, RootDatabase}; 6use ide_db::{defs::Definition, RootDatabase};
7use syntax::{ 7use syntax::{
8 ast::{self, DocCommentsOwner, NameOwner}, 8 ast::{self, DocCommentsOwner, NameOwner},
9 match_ast, AstNode, SmolStr, 9 match_ast, AstNode, SmolStr,
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs
index c25e068d6..31455709d 100644
--- a/crates/ra_ide/src/expand_macro.rs
+++ b/crates/ra_ide/src/expand_macro.rs
@@ -1,5 +1,5 @@
1use hir::Semantics; 1use hir::Semantics;
2use ra_ide_db::RootDatabase; 2use ide_db::RootDatabase;
3use syntax::{ 3use syntax::{
4 algo::{find_node_at_offset, SyntaxRewriter}, 4 algo::{find_node_at_offset, SyntaxRewriter},
5 ast, AstNode, NodeOrToken, SyntaxKind, 5 ast, AstNode, NodeOrToken, SyntaxKind,
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs
index f30df2bff..34563a026 100644
--- a/crates/ra_ide/src/extend_selection.rs
+++ b/crates/ra_ide/src/extend_selection.rs
@@ -1,7 +1,7 @@
1use std::iter::successors; 1use std::iter::successors;
2 2
3use hir::Semantics; 3use hir::Semantics;
4use ra_ide_db::RootDatabase; 4use ide_db::RootDatabase;
5use syntax::{ 5use syntax::{
6 algo::{self, find_covering_element, skip_trivia_token}, 6 algo::{self, find_covering_element, skip_trivia_token},
7 ast::{self, AstNode, AstToken}, 7 ast::{self, AstNode, AstToken},
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index b93d116bf..15e9b7fad 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -1,5 +1,5 @@
1use hir::Semantics; 1use hir::Semantics;
2use ra_ide_db::{ 2use ide_db::{
3 defs::{classify_name, classify_name_ref}, 3 defs::{classify_name, classify_name_ref},
4 symbol_index, RootDatabase, 4 symbol_index, RootDatabase,
5}; 5};
diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs
index 6dc2ccfd0..f503f4ec5 100644
--- a/crates/ra_ide/src/goto_implementation.rs
+++ b/crates/ra_ide/src/goto_implementation.rs
@@ -1,5 +1,5 @@
1use hir::{Crate, ImplDef, Semantics}; 1use hir::{Crate, ImplDef, Semantics};
2use ra_ide_db::RootDatabase; 2use ide_db::RootDatabase;
3use syntax::{algo::find_node_at_offset, ast, AstNode}; 3use syntax::{algo::find_node_at_offset, ast, AstNode};
4 4
5use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; 5use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo};
diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs
index 8017ca58c..4a151b150 100644
--- a/crates/ra_ide/src/goto_type_definition.rs
+++ b/crates/ra_ide/src/goto_type_definition.rs
@@ -1,4 +1,4 @@
1use ra_ide_db::RootDatabase; 1use ide_db::RootDatabase;
2use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; 2use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T};
3 3
4use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; 4use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo};
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index a74087f87..331aa4db0 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -3,11 +3,11 @@ use hir::{
3 Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, 3 Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay,
4 Module, ModuleDef, ModuleSource, Semantics, 4 Module, ModuleDef, ModuleSource, Semantics,
5}; 5};
6use itertools::Itertools; 6use ide_db::{
7use ra_ide_db::{
8 defs::{classify_name, classify_name_ref, Definition}, 7 defs::{classify_name, classify_name_ref, Definition},
9 RootDatabase, 8 RootDatabase,
10}; 9};
10use itertools::Itertools;
11use stdx::format_to; 11use stdx::format_to;
12use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; 12use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T};
13use test_utils::mark; 13use test_utils::mark;
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 81fe274ad..002adf915 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -1,5 +1,5 @@
1use hir::{Adt, Callable, HirDisplay, Semantics, Type}; 1use hir::{Adt, Callable, HirDisplay, Semantics, Type};
2use ra_ide_db::RootDatabase; 2use ide_db::RootDatabase;
3use stdx::to_lower_snake_case; 3use stdx::to_lower_snake_case;
4use syntax::{ 4use syntax::{
5 ast::{self, ArgListOwner, AstNode}, 5 ast::{self, ArgListOwner, AstNode},
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 789fbdaf2..bbc9e4b8a 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -3,7 +3,7 @@
3//! Strings, suitable for displaying to the human. 3//! Strings, suitable for displaying to the human.
4//! 4//!
5//! What powers this API are the `RootDatabase` struct, which defines a `salsa` 5//! What powers this API are the `RootDatabase` struct, which defines a `salsa`
6//! database, and the `ra_hir` crate, where majority of the analysis happens. 6//! database, and the `hir` crate, where majority of the analysis happens.
7//! However, IDE specific bits of the analysis (most notably completion) happen 7//! However, IDE specific bits of the analysis (most notably completion) happen
8//! in this crate. 8//! in this crate.
9 9
@@ -39,7 +39,6 @@ mod matching_brace;
39mod parent_module; 39mod parent_module;
40mod references; 40mod references;
41mod runnables; 41mod runnables;
42mod ssr;
43mod status; 42mod status;
44mod syntax_highlighting; 43mod syntax_highlighting;
45mod syntax_tree; 44mod syntax_tree;
@@ -52,7 +51,7 @@ use base_db::{
52 CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, 51 CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath,
53}; 52};
54use cfg::CfgOptions; 53use cfg::CfgOptions;
55use ra_ide_db::{ 54use ide_db::{
56 symbol_index::{self, FileSymbol}, 55 symbol_index::{self, FileSymbol},
57 LineIndexDatabase, 56 LineIndexDatabase,
58}; 57};
@@ -86,8 +85,7 @@ pub use base_db::{
86 SourceRootId, 85 SourceRootId,
87}; 86};
88pub use hir::{Documentation, Semantics}; 87pub use hir::{Documentation, Semantics};
89pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; 88pub use ide_db::{
90pub use ra_ide_db::{
91 change::AnalysisChange, 89 change::AnalysisChange,
92 line_index::{LineCol, LineIndex}, 90 line_index::{LineCol, LineIndex},
93 search::SearchScope, 91 search::SearchScope,
@@ -95,7 +93,8 @@ pub use ra_ide_db::{
95 symbol_index::Query, 93 symbol_index::Query,
96 RootDatabase, 94 RootDatabase,
97}; 95};
98pub use ra_ssr::SsrError; 96pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist};
97pub use ssr::SsrError;
99pub use text_edit::{Indel, TextEdit}; 98pub use text_edit::{Indel, TextEdit};
100 99
101pub type Cancelable<T> = Result<T, Canceled>; 100pub type Cancelable<T> = Result<T, Canceled>;
@@ -515,20 +514,23 @@ impl Analysis {
515 &self, 514 &self,
516 query: &str, 515 query: &str,
517 parse_only: bool, 516 parse_only: bool,
518 position: FilePosition, 517 resolve_context: FilePosition,
519 selections: Vec<FileRange>, 518 selections: Vec<FileRange>,
520 ) -> Cancelable<Result<SourceChange, SsrError>> { 519 ) -> Cancelable<Result<SourceChange, SsrError>> {
521 self.with_db(|db| { 520 self.with_db(|db| {
522 let edits = ssr::parse_search_replace(query, parse_only, db, position, selections)?; 521 let rule: ssr::SsrRule = query.parse()?;
522 let mut match_finder = ssr::MatchFinder::in_context(db, resolve_context, selections);
523 match_finder.add_rule(rule)?;
524 let edits = if parse_only { Vec::new() } else { match_finder.edits() };
523 Ok(SourceChange::from(edits)) 525 Ok(SourceChange::from(edits))
524 }) 526 })
525 } 527 }
526 528
527 /// Performs an operation on that may be Canceled. 529 /// Performs an operation on that may be Canceled.
528 fn with_db<F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, T>( 530 fn with_db<F, T>(&self, f: F) -> Cancelable<T>
529 &self, 531 where
530 f: F, 532 F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe,
531 ) -> Cancelable<T> { 533 {
532 self.db.catch_canceled(f) 534 self.db.catch_canceled(f)
533 } 535 }
534} 536}
diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs
index 8439e1d5d..59ed2967c 100644
--- a/crates/ra_ide/src/parent_module.rs
+++ b/crates/ra_ide/src/parent_module.rs
@@ -1,6 +1,6 @@
1use base_db::{CrateId, FileId, FilePosition}; 1use base_db::{CrateId, FileId, FilePosition};
2use hir::Semantics; 2use hir::Semantics;
3use ra_ide_db::RootDatabase; 3use ide_db::RootDatabase;
4use syntax::{ 4use syntax::{
5 algo::find_node_at_offset, 5 algo::find_node_at_offset,
6 ast::{self, AstNode}, 6 ast::{self, AstNode},
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index e89dca869..0a76ec6b4 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -12,7 +12,7 @@
12mod rename; 12mod rename;
13 13
14use hir::Semantics; 14use hir::Semantics;
15use ra_ide_db::{ 15use ide_db::{
16 defs::{classify_name, classify_name_ref, Definition}, 16 defs::{classify_name, classify_name_ref, Definition},
17 search::SearchScope, 17 search::SearchScope,
18 RootDatabase, 18 RootDatabase,
@@ -27,7 +27,7 @@ use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeI
27 27
28pub(crate) use self::rename::rename; 28pub(crate) use self::rename::rename;
29 29
30pub use ra_ide_db::search::{Reference, ReferenceAccess, ReferenceKind}; 30pub use ide_db::search::{Reference, ReferenceAccess, ReferenceKind};
31 31
32#[derive(Debug, Clone)] 32#[derive(Debug, Clone)]
33pub struct ReferenceSearchResult { 33pub struct ReferenceSearchResult {
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index 5697b9d87..d73dc9cd0 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -2,7 +2,7 @@
2 2
3use base_db::SourceDatabaseExt; 3use base_db::SourceDatabaseExt;
4use hir::{Module, ModuleDef, ModuleSource, Semantics}; 4use hir::{Module, ModuleDef, ModuleSource, Semantics};
5use ra_ide_db::{ 5use ide_db::{
6 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, 6 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
7 RootDatabase, 7 RootDatabase,
8}; 8};
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs
index fb40762cf..c3e07c8de 100644
--- a/crates/ra_ide/src/runnables.rs
+++ b/crates/ra_ide/src/runnables.rs
@@ -2,8 +2,8 @@ use std::fmt;
2 2
3use cfg::CfgExpr; 3use cfg::CfgExpr;
4use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; 4use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics};
5use ide_db::RootDatabase;
5use itertools::Itertools; 6use itertools::Itertools;
6use ra_ide_db::RootDatabase;
7use syntax::{ 7use syntax::{
8 ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, 8 ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner},
9 match_ast, SyntaxNode, 9 match_ast, SyntaxNode,
diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs
deleted file mode 100644
index 97b82b70e..000000000
--- a/crates/ra_ide/src/ssr.rs
+++ /dev/null
@@ -1,72 +0,0 @@
1use base_db::{FilePosition, FileRange};
2use ra_ide_db::RootDatabase;
3
4use crate::SourceFileEdit;
5use ra_ssr::{MatchFinder, SsrError, SsrRule};
6
7// Feature: Structural Search and Replace
8//
9// Search and replace with named wildcards that will match any expression, type, path, pattern or item.
10// The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`.
11// A `$<name>` placeholder in the search pattern will match any AST node and `$<name>` will reference it in the replacement.
12// Within a macro call, a placeholder will match up until whatever token follows the placeholder.
13//
14// All paths in both the search pattern and the replacement template must resolve in the context
15// in which this command is invoked. Paths in the search pattern will then match the code if they
16// resolve to the same item, even if they're written differently. For example if we invoke the
17// command in the module `foo` with a pattern of `Bar`, then code in the parent module that refers
18// to `foo::Bar` will match.
19//
20// Paths in the replacement template will be rendered appropriately for the context in which the
21// replacement occurs. For example if our replacement template is `foo::Bar` and we match some
22// code in the `foo` module, we'll insert just `Bar`.
23//
24// Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will
25// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`.
26//
27// The scope of the search / replace will be restricted to the current selection if any, otherwise
28// it will apply to the whole workspace.
29//
30// Placeholders may be given constraints by writing them as `${<name>:<constraint1>:<constraint2>...}`.
31//
32// Supported constraints:
33//
34// |===
35// | Constraint | Restricts placeholder
36//
37// | kind(literal) | Is a literal (e.g. `42` or `"forty two"`)
38// | not(a) | Negates the constraint `a`
39// |===
40//
41// Available via the command `rust-analyzer.ssr`.
42//
43// ```rust
44// // Using structural search replace command [foo($a, $b) ==>> ($a).foo($b)]
45//
46// // BEFORE
47// String::from(foo(y + 5, z))
48//
49// // AFTER
50// String::from((y + 5).foo(z))
51// ```
52//
53// |===
54// | Editor | Action Name
55//
56// | VS Code | **Rust Analyzer: Structural Search Replace**
57// |===
58pub fn parse_search_replace(
59 rule: &str,
60 parse_only: bool,
61 db: &RootDatabase,
62 resolve_context: FilePosition,
63 selections: Vec<FileRange>,
64) -> Result<Vec<SourceFileEdit>, SsrError> {
65 let rule: SsrRule = rule.parse()?;
66 let mut match_finder = MatchFinder::in_context(db, resolve_context, selections);
67 match_finder.add_rule(rule)?;
68 if parse_only {
69 return Ok(Vec::new());
70 }
71 Ok(match_finder.edits())
72}
diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs
index 869c74acc..c23708181 100644
--- a/crates/ra_ide/src/status.rs
+++ b/crates/ra_ide/src/status.rs
@@ -5,11 +5,11 @@ use base_db::{
5 FileTextQuery, SourceRootId, 5 FileTextQuery, SourceRootId,
6}; 6};
7use hir::MacroFile; 7use hir::MacroFile;
8use profile::{memory_usage, Bytes}; 8use ide_db::{
9use ra_ide_db::{
10 symbol_index::{LibrarySymbolsQuery, SymbolIndex}, 9 symbol_index::{LibrarySymbolsQuery, SymbolIndex},
11 RootDatabase, 10 RootDatabase,
12}; 11};
12use profile::{memory_usage, Bytes};
13use rustc_hash::FxHashMap; 13use rustc_hash::FxHashMap;
14use syntax::{ast, Parse, SyntaxNode}; 14use syntax::{ast, Parse, SyntaxNode};
15 15
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 4b41ceb1d..5d7c7e8d0 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -5,7 +5,7 @@ mod injection;
5mod tests; 5mod tests;
6 6
7use hir::{Name, Semantics, VariantDef}; 7use hir::{Name, Semantics, VariantDef};
8use ra_ide_db::{ 8use ide_db::{
9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, 9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
10 RootDatabase, 10 RootDatabase,
11}; 11};
diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs
index 17daf06b6..f80044959 100644
--- a/crates/ra_ide/src/syntax_tree.rs
+++ b/crates/ra_ide/src/syntax_tree.rs
@@ -1,5 +1,5 @@
1use base_db::{FileId, SourceDatabase}; 1use base_db::{FileId, SourceDatabase};
2use ra_ide_db::RootDatabase; 2use ide_db::RootDatabase;
3use syntax::{ 3use syntax::{
4 algo, AstNode, NodeOrToken, SourceFile, 4 algo, AstNode, NodeOrToken, SourceFile,
5 SyntaxKind::{RAW_STRING, STRING}, 5 SyntaxKind::{RAW_STRING, STRING},
diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs
index 75f2a6b60..899ce5f26 100644
--- a/crates/ra_ide/src/typing.rs
+++ b/crates/ra_ide/src/typing.rs
@@ -16,7 +16,7 @@
16mod on_enter; 16mod on_enter;
17 17
18use base_db::{FilePosition, SourceDatabase}; 18use base_db::{FilePosition, SourceDatabase};
19use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; 19use ide_db::{source_change::SourceFileEdit, RootDatabase};
20use syntax::{ 20use syntax::{
21 algo::find_node_at_offset, 21 algo::find_node_at_offset,
22 ast::{self, edit::IndentLevel, AstToken}, 22 ast::{self, edit::IndentLevel, AstToken},
diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs
index 193930659..f7d46146c 100644
--- a/crates/ra_ide/src/typing/on_enter.rs
+++ b/crates/ra_ide/src/typing/on_enter.rs
@@ -2,7 +2,7 @@
2//! comments, but should handle indent some time in the future as well. 2//! comments, but should handle indent some time in the future as well.
3 3
4use base_db::{FilePosition, SourceDatabase}; 4use base_db::{FilePosition, SourceDatabase};
5use ra_ide_db::RootDatabase; 5use ide_db::RootDatabase;
6use syntax::{ 6use syntax::{
7 ast::{self, AstToken}, 7 ast::{self, AstToken},
8 AstNode, SmolStr, SourceFile, 8 AstNode, SmolStr, SourceFile,
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 0dee719de..749cf648c 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -47,11 +47,11 @@ toolchain = { path = "../toolchain" }
47 47
48# This should only be used in CLI 48# This should only be used in CLI
49base_db = { path = "../base_db" } 49base_db = { path = "../base_db" }
50ra_ide_db = { path = "../ra_ide_db" } 50ide_db = { path = "../ide_db" }
51ra_ssr = { path = "../ra_ssr" } 51ssr = { path = "../ssr" }
52hir = { path = "../ra_hir", package = "ra_hir" } 52hir = { path = "../hir" }
53hir_def = { path = "../hir_def" } 53hir_def = { path = "../hir_def" }
54hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } 54hir_ty = { path = "../hir_ty" }
55proc_macro_srv = { path = "../proc_macro_srv" } 55proc_macro_srv = { path = "../proc_macro_srv" }
56 56
57[target.'cfg(windows)'.dependencies] 57[target.'cfg(windows)'.dependencies]
diff --git a/crates/rust-analyzer/src/bin/args.rs b/crates/rust-analyzer/src/bin/args.rs
index d3081e88b..0bc92431a 100644
--- a/crates/rust-analyzer/src/bin/args.rs
+++ b/crates/rust-analyzer/src/bin/args.rs
@@ -7,8 +7,8 @@ use std::{env, fmt::Write, path::PathBuf};
7 7
8use anyhow::{bail, Result}; 8use anyhow::{bail, Result};
9use pico_args::Arguments; 9use pico_args::Arguments;
10use ra_ssr::{SsrPattern, SsrRule};
11use rust_analyzer::cli::{AnalysisStatsCmd, BenchCmd, BenchWhat, Position, Verbosity}; 10use rust_analyzer::cli::{AnalysisStatsCmd, BenchCmd, BenchWhat, Position, Verbosity};
11use ssr::{SsrPattern, SsrRule};
12use vfs::AbsPathBuf; 12use vfs::AbsPathBuf;
13 13
14pub(crate) struct Args { 14pub(crate) struct Args {
diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs
index 420abaccb..b237a94d1 100644
--- a/crates/rust-analyzer/src/cli.rs
+++ b/crates/rust-analyzer/src/cli.rs
@@ -13,11 +13,13 @@ use anyhow::Result;
13use ra_ide::Analysis; 13use ra_ide::Analysis;
14use syntax::{AstNode, SourceFile}; 14use syntax::{AstNode, SourceFile};
15 15
16pub use analysis_bench::{BenchCmd, BenchWhat, Position}; 16pub use self::{
17pub use analysis_stats::AnalysisStatsCmd; 17 analysis_bench::{BenchCmd, BenchWhat, Position},
18pub use diagnostics::diagnostics; 18 analysis_stats::AnalysisStatsCmd,
19pub use load_cargo::load_cargo; 19 diagnostics::diagnostics,
20pub use ssr::{apply_ssr_rules, search_for_patterns}; 20 load_cargo::load_cargo,
21 ssr::{apply_ssr_rules, search_for_patterns},
22};
21 23
22#[derive(Clone, Copy)] 24#[derive(Clone, Copy)]
23pub enum Verbosity { 25pub enum Verbosity {
diff --git a/crates/rust-analyzer/src/cli/ssr.rs b/crates/rust-analyzer/src/cli/ssr.rs
index 08788fb41..c11e10943 100644
--- a/crates/rust-analyzer/src/cli/ssr.rs
+++ b/crates/rust-analyzer/src/cli/ssr.rs
@@ -1,7 +1,7 @@
1//! Applies structured search replace rules from the command line. 1//! Applies structured search replace rules from the command line.
2 2
3use crate::cli::{load_cargo::load_cargo, Result}; 3use crate::cli::{load_cargo::load_cargo, Result};
4use ra_ssr::{MatchFinder, SsrPattern, SsrRule}; 4use ssr::{MatchFinder, SsrPattern, SsrRule};
5 5
6pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> { 6pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
7 use base_db::SourceDatabaseExt; 7 use base_db::SourceDatabaseExt;
@@ -27,7 +27,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
27/// for much else. 27/// for much else.
28pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> { 28pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> {
29 use base_db::SourceDatabaseExt; 29 use base_db::SourceDatabaseExt;
30 use ra_ide_db::symbol_index::SymbolsDatabase; 30 use ide_db::symbol_index::SymbolsDatabase;
31 let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?; 31 let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
32 let db = host.raw_database(); 32 let db = host.raw_database();
33 let mut match_finder = MatchFinder::at_first_file(db)?; 33 let mut match_finder = MatchFinder::at_first_file(db)?;
diff --git a/crates/ra_ssr/Cargo.toml b/crates/ssr/Cargo.toml
index f290939cf..cd05eeecc 100644
--- a/crates/ra_ssr/Cargo.toml
+++ b/crates/ssr/Cargo.toml
@@ -1,22 +1,23 @@
1[package] 1[package]
2edition = "2018" 2name = "ssr"
3name = "ra_ssr"
4version = "0.1.0" 3version = "0.1.0"
5authors = ["rust-analyzer developers"]
6license = "MIT OR Apache-2.0"
7description = "Structural search and replace of Rust code" 4description = "Structural search and replace of Rust code"
5license = "MIT OR Apache-2.0"
8repository = "https://github.com/rust-analyzer/rust-analyzer" 6repository = "https://github.com/rust-analyzer/rust-analyzer"
7authors = ["rust-analyzer developers"]
8edition = "2018"
9 9
10[lib] 10[lib]
11doctest = false 11doctest = false
12 12
13[dependencies] 13[dependencies]
14rustc-hash = "1.1.0"
15
14text_edit = { path = "../text_edit" } 16text_edit = { path = "../text_edit" }
15syntax = { path = "../syntax" } 17syntax = { path = "../syntax" }
16base_db = { path = "../base_db" } 18base_db = { path = "../base_db" }
17ra_ide_db = { path = "../ra_ide_db" } 19ide_db = { path = "../ide_db" }
18hir = { path = "../ra_hir", package = "ra_hir" } 20hir = { path = "../hir" }
19rustc-hash = "1.1.0"
20test_utils = { path = "../test_utils" } 21test_utils = { path = "../test_utils" }
21 22
22[dev-dependencies] 23[dev-dependencies]
diff --git a/crates/ra_ssr/src/errors.rs b/crates/ssr/src/errors.rs
index c02bacae6..c02bacae6 100644
--- a/crates/ra_ssr/src/errors.rs
+++ b/crates/ssr/src/errors.rs
diff --git a/crates/ra_ssr/src/lib.rs b/crates/ssr/src/lib.rs
index 6725582e4..292bd5b9a 100644
--- a/crates/ra_ssr/src/lib.rs
+++ b/crates/ssr/src/lib.rs
@@ -3,6 +3,58 @@
3//! Allows searching the AST for code that matches one or more patterns and then replacing that code 3//! Allows searching the AST for code that matches one or more patterns and then replacing that code
4//! based on a template. 4//! based on a template.
5 5
6// Feature: Structural Search and Replace
7//
8// Search and replace with named wildcards that will match any expression, type, path, pattern or item.
9// The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`.
10// A `$<name>` placeholder in the search pattern will match any AST node and `$<name>` will reference it in the replacement.
11// Within a macro call, a placeholder will match up until whatever token follows the placeholder.
12//
13// All paths in both the search pattern and the replacement template must resolve in the context
14// in which this command is invoked. Paths in the search pattern will then match the code if they
15// resolve to the same item, even if they're written differently. For example if we invoke the
16// command in the module `foo` with a pattern of `Bar`, then code in the parent module that refers
17// to `foo::Bar` will match.
18//
19// Paths in the replacement template will be rendered appropriately for the context in which the
20// replacement occurs. For example if our replacement template is `foo::Bar` and we match some
21// code in the `foo` module, we'll insert just `Bar`.
22//
23// Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will
24// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`.
25//
26// The scope of the search / replace will be restricted to the current selection if any, otherwise
27// it will apply to the whole workspace.
28//
29// Placeholders may be given constraints by writing them as `${<name>:<constraint1>:<constraint2>...}`.
30//
31// Supported constraints:
32//
33// |===
34// | Constraint | Restricts placeholder
35//
36// | kind(literal) | Is a literal (e.g. `42` or `"forty two"`)
37// | not(a) | Negates the constraint `a`
38// |===
39//
40// Available via the command `rust-analyzer.ssr`.
41//
42// ```rust
43// // Using structural search replace command [foo($a, $b) ==>> ($a).foo($b)]
44//
45// // BEFORE
46// String::from(foo(y + 5, z))
47//
48// // AFTER
49// String::from((y + 5).foo(z))
50// ```
51//
52// |===
53// | Editor | Action Name
54//
55// | VS Code | **Rust Analyzer: Structural Search Replace**
56// |===
57
6mod matching; 58mod matching;
7mod nester; 59mod nester;
8mod parsing; 60mod parsing;
@@ -20,7 +72,7 @@ pub use crate::matching::Match;
20use crate::matching::MatchFailureReason; 72use crate::matching::MatchFailureReason;
21use base_db::{FileId, FilePosition, FileRange}; 73use base_db::{FileId, FilePosition, FileRange};
22use hir::Semantics; 74use hir::Semantics;
23use ra_ide_db::source_change::SourceFileEdit; 75use ide_db::source_change::SourceFileEdit;
24use resolving::ResolvedRule; 76use resolving::ResolvedRule;
25use rustc_hash::FxHashMap; 77use rustc_hash::FxHashMap;
26use syntax::{ast, AstNode, SyntaxNode, TextRange}; 78use syntax::{ast, AstNode, SyntaxNode, TextRange};
@@ -49,7 +101,7 @@ pub struct SsrMatches {
49/// Searches a crate for pattern matches and possibly replaces them with something else. 101/// Searches a crate for pattern matches and possibly replaces them with something else.
50pub struct MatchFinder<'db> { 102pub struct MatchFinder<'db> {
51 /// Our source of information about the user's code. 103 /// Our source of information about the user's code.
52 sema: Semantics<'db, ra_ide_db::RootDatabase>, 104 sema: Semantics<'db, ide_db::RootDatabase>,
53 rules: Vec<ResolvedRule>, 105 rules: Vec<ResolvedRule>,
54 resolution_scope: resolving::ResolutionScope<'db>, 106 resolution_scope: resolving::ResolutionScope<'db>,
55 restrict_ranges: Vec<FileRange>, 107 restrict_ranges: Vec<FileRange>,
@@ -59,7 +111,7 @@ impl<'db> MatchFinder<'db> {
59 /// Constructs a new instance where names will be looked up as if they appeared at 111 /// Constructs a new instance where names will be looked up as if they appeared at
60 /// `lookup_context`. 112 /// `lookup_context`.
61 pub fn in_context( 113 pub fn in_context(
62 db: &'db ra_ide_db::RootDatabase, 114 db: &'db ide_db::RootDatabase,
63 lookup_context: FilePosition, 115 lookup_context: FilePosition,
64 mut restrict_ranges: Vec<FileRange>, 116 mut restrict_ranges: Vec<FileRange>,
65 ) -> MatchFinder<'db> { 117 ) -> MatchFinder<'db> {
@@ -70,9 +122,9 @@ impl<'db> MatchFinder<'db> {
70 } 122 }
71 123
72 /// Constructs an instance using the start of the first file in `db` as the lookup context. 124 /// Constructs an instance using the start of the first file in `db` as the lookup context.
73 pub fn at_first_file(db: &'db ra_ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> { 125 pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> {
74 use base_db::SourceDatabaseExt; 126 use base_db::SourceDatabaseExt;
75 use ra_ide_db::symbol_index::SymbolsDatabase; 127 use ide_db::symbol_index::SymbolsDatabase;
76 if let Some(first_file_id) = db 128 if let Some(first_file_id) = db
77 .local_roots() 129 .local_roots()
78 .iter() 130 .iter()
diff --git a/crates/ra_ssr/src/matching.rs b/crates/ssr/src/matching.rs
index e81a87c47..ffc7202ae 100644
--- a/crates/ra_ssr/src/matching.rs
+++ b/crates/ssr/src/matching.rs
@@ -92,7 +92,7 @@ pub(crate) fn get_match(
92 rule: &ResolvedRule, 92 rule: &ResolvedRule,
93 code: &SyntaxNode, 93 code: &SyntaxNode,
94 restrict_range: &Option<FileRange>, 94 restrict_range: &Option<FileRange>,
95 sema: &Semantics<ra_ide_db::RootDatabase>, 95 sema: &Semantics<ide_db::RootDatabase>,
96) -> Result<Match, MatchFailed> { 96) -> Result<Match, MatchFailed> {
97 record_match_fails_reasons_scope(debug_active, || { 97 record_match_fails_reasons_scope(debug_active, || {
98 Matcher::try_match(rule, code, restrict_range, sema) 98 Matcher::try_match(rule, code, restrict_range, sema)
@@ -101,7 +101,7 @@ pub(crate) fn get_match(
101 101
102/// Checks if our search pattern matches a particular node of the AST. 102/// Checks if our search pattern matches a particular node of the AST.
103struct Matcher<'db, 'sema> { 103struct Matcher<'db, 'sema> {
104 sema: &'sema Semantics<'db, ra_ide_db::RootDatabase>, 104 sema: &'sema Semantics<'db, ide_db::RootDatabase>,
105 /// If any placeholders come from anywhere outside of this range, then the match will be 105 /// If any placeholders come from anywhere outside of this range, then the match will be
106 /// rejected. 106 /// rejected.
107 restrict_range: Option<FileRange>, 107 restrict_range: Option<FileRange>,
@@ -123,7 +123,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
123 rule: &ResolvedRule, 123 rule: &ResolvedRule,
124 code: &SyntaxNode, 124 code: &SyntaxNode,
125 restrict_range: &Option<FileRange>, 125 restrict_range: &Option<FileRange>,
126 sema: &'sema Semantics<'db, ra_ide_db::RootDatabase>, 126 sema: &'sema Semantics<'db, ide_db::RootDatabase>,
127 ) -> Result<Match, MatchFailed> { 127 ) -> Result<Match, MatchFailed> {
128 let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule }; 128 let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule };
129 // First pass at matching, where we check that node types and idents match. 129 // First pass at matching, where we check that node types and idents match.
@@ -606,7 +606,7 @@ impl Match {
606 fn render_template_paths( 606 fn render_template_paths(
607 &mut self, 607 &mut self,
608 template: &ResolvedPattern, 608 template: &ResolvedPattern,
609 sema: &Semantics<ra_ide_db::RootDatabase>, 609 sema: &Semantics<ide_db::RootDatabase>,
610 ) -> Result<(), MatchFailed> { 610 ) -> Result<(), MatchFailed> {
611 let module = sema 611 let module = sema
612 .scope(&self.matched_node) 612 .scope(&self.matched_node)
diff --git a/crates/ra_ssr/src/nester.rs b/crates/ssr/src/nester.rs
index 8be570d3c..6ac355dfc 100644
--- a/crates/ra_ssr/src/nester.rs
+++ b/crates/ssr/src/nester.rs
@@ -13,7 +13,7 @@ use syntax::SyntaxNode;
13 13
14pub(crate) fn nest_and_remove_collisions( 14pub(crate) fn nest_and_remove_collisions(
15 mut matches: Vec<Match>, 15 mut matches: Vec<Match>,
16 sema: &hir::Semantics<ra_ide_db::RootDatabase>, 16 sema: &hir::Semantics<ide_db::RootDatabase>,
17) -> SsrMatches { 17) -> SsrMatches {
18 // We sort the matches by depth then by rule index. Sorting by depth means that by the time we 18 // We sort the matches by depth then by rule index. Sorting by depth means that by the time we
19 // see a match, any parent matches or conflicting matches will have already been seen. Sorting 19 // see a match, any parent matches or conflicting matches will have already been seen. Sorting
@@ -36,7 +36,7 @@ impl MatchCollector {
36 /// Attempts to add `m` to matches. If it conflicts with an existing match, it is discarded. If 36 /// Attempts to add `m` to matches. If it conflicts with an existing match, it is discarded. If
37 /// it is entirely within the a placeholder of an existing match, then it is added as a child 37 /// it is entirely within the a placeholder of an existing match, then it is added as a child
38 /// match of the existing match. 38 /// match of the existing match.
39 fn add_match(&mut self, m: Match, sema: &hir::Semantics<ra_ide_db::RootDatabase>) { 39 fn add_match(&mut self, m: Match, sema: &hir::Semantics<ide_db::RootDatabase>) {
40 let matched_node = m.matched_node.clone(); 40 let matched_node = m.matched_node.clone();
41 if let Some(existing) = self.matches_by_node.get_mut(&matched_node) { 41 if let Some(existing) = self.matches_by_node.get_mut(&matched_node) {
42 try_add_sub_match(m, existing, sema); 42 try_add_sub_match(m, existing, sema);
@@ -53,11 +53,7 @@ impl MatchCollector {
53} 53}
54 54
55/// Attempts to add `m` as a sub-match of `existing`. 55/// Attempts to add `m` as a sub-match of `existing`.
56fn try_add_sub_match( 56fn try_add_sub_match(m: Match, existing: &mut Match, sema: &hir::Semantics<ide_db::RootDatabase>) {
57 m: Match,
58 existing: &mut Match,
59 sema: &hir::Semantics<ra_ide_db::RootDatabase>,
60) {
61 for p in existing.placeholder_values.values_mut() { 57 for p in existing.placeholder_values.values_mut() {
62 // Note, no need to check if p.range.file is equal to m.range.file, since we 58 // Note, no need to check if p.range.file is equal to m.range.file, since we
63 // already know we're within `existing`. 59 // already know we're within `existing`.
diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ssr/src/parsing.rs
index 9570e96e3..9570e96e3 100644
--- a/crates/ra_ssr/src/parsing.rs
+++ b/crates/ssr/src/parsing.rs
diff --git a/crates/ra_ssr/src/replacing.rs b/crates/ssr/src/replacing.rs
index 8f8fe6149..8f8fe6149 100644
--- a/crates/ra_ssr/src/replacing.rs
+++ b/crates/ssr/src/replacing.rs
diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ssr/src/resolving.rs
index dac09bae8..020fd7994 100644
--- a/crates/ra_ssr/src/resolving.rs
+++ b/crates/ssr/src/resolving.rs
@@ -187,7 +187,7 @@ impl Resolver<'_, '_> {
187 187
188impl<'db> ResolutionScope<'db> { 188impl<'db> ResolutionScope<'db> {
189 pub(crate) fn new( 189 pub(crate) fn new(
190 sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>, 190 sema: &hir::Semantics<'db, ide_db::RootDatabase>,
191 resolve_context: FilePosition, 191 resolve_context: FilePosition,
192 ) -> ResolutionScope<'db> { 192 ) -> ResolutionScope<'db> {
193 use syntax::ast::AstNode; 193 use syntax::ast::AstNode;
diff --git a/crates/ra_ssr/src/search.rs b/crates/ssr/src/search.rs
index 434953fb4..8509cfa4d 100644
--- a/crates/ra_ssr/src/search.rs
+++ b/crates/ssr/src/search.rs
@@ -6,7 +6,7 @@ use crate::{
6 Match, MatchFinder, 6 Match, MatchFinder,
7}; 7};
8use base_db::{FileId, FileRange}; 8use base_db::{FileId, FileRange};
9use ra_ide_db::{ 9use ide_db::{
10 defs::Definition, 10 defs::Definition,
11 search::{Reference, SearchScope}, 11 search::{Reference, SearchScope},
12}; 12};
@@ -146,7 +146,7 @@ impl<'db> MatchFinder<'db> {
146 if self.restrict_ranges.is_empty() { 146 if self.restrict_ranges.is_empty() {
147 // Unrestricted search. 147 // Unrestricted search.
148 use base_db::SourceDatabaseExt; 148 use base_db::SourceDatabaseExt;
149 use ra_ide_db::symbol_index::SymbolsDatabase; 149 use ide_db::symbol_index::SymbolsDatabase;
150 for &root in self.sema.db.local_roots().iter() { 150 for &root in self.sema.db.local_roots().iter() {
151 let sr = self.sema.db.source_root(root); 151 let sr = self.sema.db.source_root(root);
152 for file_id in sr.iter() { 152 for file_id in sr.iter() {
diff --git a/crates/ra_ssr/src/tests.rs b/crates/ssr/src/tests.rs
index 54c3da9db..0d0a00090 100644
--- a/crates/ra_ssr/src/tests.rs
+++ b/crates/ssr/src/tests.rs
@@ -61,13 +61,13 @@ fn parser_undefined_placeholder_in_replacement() {
61 61
62/// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be 62/// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be
63/// the start of the file. If there's a second cursor marker, then we'll return a single range. 63/// the start of the file. If there's a second cursor marker, then we'll return a single range.
64pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, Vec<FileRange>) { 64pub(crate) fn single_file(code: &str) -> (ide_db::RootDatabase, FilePosition, Vec<FileRange>) {
65 use base_db::fixture::WithFixture; 65 use base_db::fixture::WithFixture;
66 use ra_ide_db::symbol_index::SymbolsDatabase; 66 use ide_db::symbol_index::SymbolsDatabase;
67 let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) { 67 let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) {
68 ra_ide_db::RootDatabase::with_range_or_offset(code) 68 ide_db::RootDatabase::with_range_or_offset(code)
69 } else { 69 } else {
70 let (db, file_id) = ra_ide_db::RootDatabase::with_single_file(code); 70 let (db, file_id) = ide_db::RootDatabase::with_single_file(code);
71 (db, file_id, RangeOrOffset::Offset(0.into())) 71 (db, file_id, RangeOrOffset::Offset(0.into()))
72 }; 72 };
73 let selections; 73 let selections;
diff --git a/docs/dev/README.md b/docs/dev/README.md
index 4aab6e2b8..04bebbfca 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -148,14 +148,14 @@ Internal representations are lowered to LSP in the `rust-analyzer` crate (the on
148 148
149## IDE/Compiler split 149## IDE/Compiler split
150 150
151There's a semi-hard split between "compiler" and "IDE", at the `ra_hir` crate. 151There's a semi-hard split between "compiler" and "IDE", at the `hir` crate.
152Compiler derives new facts about source code. 152Compiler derives new facts about source code.
153It explicitly acknowledges that not all info is available (i.e. you can't look at types during name resolution). 153It explicitly acknowledges that not all info is available (i.e. you can't look at types during name resolution).
154 154
155IDE assumes that all information is available at all times. 155IDE assumes that all information is available at all times.
156 156
157IDE should use only types from `ra_hir`, and should not depend on the underling compiler types. 157IDE should use only types from `hir`, and should not depend on the underling compiler types.
158`ra_hir` is a facade. 158`hir` is a facade.
159 159
160## IDE API 160## IDE API
161 161
diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md
index 746d41f83..0ffe61026 100644
--- a/docs/dev/architecture.md
+++ b/docs/dev/architecture.md
@@ -102,7 +102,7 @@ defines most of the "input" queries: facts supplied by the client of the
102analyzer. Reading the docs of the `base_db::input` module should be useful: 102analyzer. Reading the docs of the `base_db::input` module should be useful:
103everything else is strictly derived from those inputs. 103everything else is strictly derived from those inputs.
104 104
105### `crates/ra_hir*` crates 105### `crates/hir*` crates
106 106
107HIR provides high-level "object oriented" access to Rust code. 107HIR provides high-level "object oriented" access to Rust code.
108 108
@@ -113,10 +113,10 @@ is responsible for guessing a HIR for a particular source position.
113 113
114Underneath, HIR works on top of salsa, using a `HirDatabase` trait. 114Underneath, HIR works on top of salsa, using a `HirDatabase` trait.
115 115
116`ra_hir_xxx` crates have a strong ECS flavor, in that they work with raw ids and 116`hir_xxx` crates have a strong ECS flavor, in that they work with raw ids and
117directly query the database. 117directly query the database.
118 118
119The top-level `ra_hir` façade crate wraps ids into a more OO-flavored API. 119The top-level `hir` façade crate wraps ids into a more OO-flavored API.
120 120
121### `crates/ra_ide` 121### `crates/ra_ide`
122 122
diff --git a/docs/dev/guide.md b/docs/dev/guide.md
index d14143226..29d84bf3f 100644
--- a/docs/dev/guide.md
+++ b/docs/dev/guide.md
@@ -275,7 +275,7 @@ several times, with different sets of `cfg`s enabled. The IDE-specific task of
275mapping source code position into a semantic model is inherently imprecise for 275mapping source code position into a semantic model is inherently imprecise for
276this reason, and is handled by the [`source_binder`]. 276this reason, and is handled by the [`source_binder`].
277 277
278[`source_binder`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/source_binder.rs 278[`source_binder`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/source_binder.rs
279 279
280The semantic interface is declared in the [`code_model_api`] module. Each entity is 280The semantic interface is declared in the [`code_model_api`] module. Each entity is
281identified by an integer ID and has a bunch of methods which take a salsa database 281identified by an integer ID and has a bunch of methods which take a salsa database
@@ -283,8 +283,8 @@ as an argument and returns other entities (which are also IDs). Internally, thes
283methods invoke various queries on the database to build the model on demand. 283methods invoke various queries on the database to build the model on demand.
284Here's [the list of queries]. 284Here's [the list of queries].
285 285
286[`code_model_api`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/code_model_api.rs 286[`code_model_api`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/code_model_api.rs
287[the list of queries]: https://github.com/rust-analyzer/rust-analyzer/blob/7e84440e25e19529e4ff8a66e521d1b06349c6ec/crates/ra_hir/src/db.rs#L20-L106 287[the list of queries]: https://github.com/rust-analyzer/rust-analyzer/blob/7e84440e25e19529e4ff8a66e521d1b06349c6ec/crates/hir/src/db.rs#L20-L106
288 288
289The first step of building the model is parsing the source code. 289The first step of building the model is parsing the source code.
290 290
@@ -341,7 +341,7 @@ The algorithm for building a tree of modules is to start with a crate root
341declarations and recursively process child modules. This is handled by the 341declarations and recursively process child modules. This is handled by the
342[`module_tree_query`], with two slight variations. 342[`module_tree_query`], with two slight variations.
343 343
344[`module_tree_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L116-L123 344[`module_tree_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/module_tree.rs#L116-L123
345 345
346First, rust-analyzer builds a module tree for all crates in a source root 346First, rust-analyzer builds a module tree for all crates in a source root
347simultaneously. The main reason for this is historical (`module_tree` predates 347simultaneously. The main reason for this is historical (`module_tree` predates
@@ -364,7 +364,7 @@ the same, we don't have to re-execute [`module_tree_query`]. In fact, we only
364need to re-execute it when we add/remove new files or when we change mod 364need to re-execute it when we add/remove new files or when we change mod
365declarations. 365declarations.
366 366
367[`submodules_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L41 367[`submodules_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/module_tree.rs#L41
368 368
369We store the resulting modules in a `Vec`-based indexed arena. The indices in 369We store the resulting modules in a `Vec`-based indexed arena. The indices in
370the arena becomes module IDs. And this brings us to the next topic: 370the arena becomes module IDs. And this brings us to the next topic:
@@ -393,7 +393,7 @@ database we use includes a couple of [interners]. How to "garbage collect"
393unused locations is an open question. 393unused locations is an open question.
394 394
395[`LocationInterner`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/base_db/src/loc2id.rs#L65-L71 395[`LocationInterner`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/base_db/src/loc2id.rs#L65-L71
396[interners]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/db.rs#L22-L23 396[interners]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/db.rs#L22-L23
397 397
398For example, we use `LocationInterner` to assign IDs to definitions of functions, 398For example, we use `LocationInterner` to assign IDs to definitions of functions,
399structs, enums, etc. The location, [`DefLoc`] contains two bits of information: 399structs, enums, etc. The location, [`DefLoc`] contains two bits of information:
@@ -407,7 +407,7 @@ using offsets, text ranges or syntax trees as keys and values for queries. What
407we do instead is we store "index" of the item among all of the items of a file 407we do instead is we store "index" of the item among all of the items of a file
408(so, a positional based ID, but localized to a single file). 408(so, a positional based ID, but localized to a single file).
409 409
410[`DefLoc`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ids.rs#L127-L139 410[`DefLoc`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/ids.rs#L127-L139
411 411
412One thing we've glossed over for the time being is support for macros. We have 412One thing we've glossed over for the time being is support for macros. We have
413only proof of concept handling of macros at the moment, but they are extremely 413only proof of concept handling of macros at the moment, but they are extremely
@@ -440,7 +440,7 @@ terms of `HirFileId`! This does not recur infinitely though: any chain of
440`HirFileId`s bottoms out in `HirFileId::FileId`, that is, some source file 440`HirFileId`s bottoms out in `HirFileId::FileId`, that is, some source file
441actually written by the user. 441actually written by the user.
442 442
443[`HirFileId`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ids.rs#L18-L125 443[`HirFileId`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/ids.rs#L18-L125
444 444
445Now that we understand how to identify a definition, in a source or in a 445Now that we understand how to identify a definition, in a source or in a
446macro-generated file, we can discuss name resolution a bit. 446macro-generated file, we can discuss name resolution a bit.
@@ -454,14 +454,14 @@ each module into a position-independent representation which does not change if
454we modify bodies of the items. After that we [loop] resolving all imports until 454we modify bodies of the items. After that we [loop] resolving all imports until
455we've reached a fixed point. 455we've reached a fixed point.
456 456
457[lower]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L113-L117 457[lower]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L113-L117
458[loop]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres.rs#L186-L196 458[loop]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres.rs#L186-L196
459 459
460And, given all our preparation with IDs and a position-independent representation, 460And, given all our preparation with IDs and a position-independent representation,
461it is satisfying to [test] that typing inside function body does not invalidate 461it is satisfying to [test] that typing inside function body does not invalidate
462name resolution results. 462name resolution results.
463 463
464[test]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/tests.rs#L376 464[test]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/tests.rs#L376
465 465
466An interesting fact about name resolution is that it "erases" all of the 466An interesting fact about name resolution is that it "erases" all of the
467intermediate paths from the imports: in the end, we know which items are defined 467intermediate paths from the imports: in the end, we know which items are defined
@@ -496,10 +496,10 @@ there's an intermediate [projection query] which returns only the first
496position-independent part of the lowering. The result of this query is stable. 496position-independent part of the lowering. The result of this query is stable.
497Naturally, name resolution [uses] this stable projection query. 497Naturally, name resolution [uses] this stable projection query.
498 498
499[imports]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L52-L59 499[imports]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L52-L59
500[`SourceMap`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L52-L59 500[`SourceMap`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L52-L59
501[projection query]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L97-L103 501[projection query]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L97-L103
502[uses]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/query_definitions.rs#L49 502[uses]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/query_definitions.rs#L49
503 503
504## Type inference 504## Type inference
505 505
@@ -521,10 +521,10 @@ construct a mapping from `ExprId`s to types.
521 521
522[@flodiebold]: https://github.com/flodiebold 522[@flodiebold]: https://github.com/flodiebold
523[#327]: https://github.com/rust-analyzer/rust-analyzer/pull/327 523[#327]: https://github.com/rust-analyzer/rust-analyzer/pull/327
524[lower the AST]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs 524[lower the AST]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs
525[positional ID]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs#L13-L15 525[positional ID]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs#L13-L15
526[a source map]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs#L41-L44 526[a source map]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs#L41-L44
527[type inference]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ty.rs#L1208-L1223 527[type inference]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/ty.rs#L1208-L1223
528 528
529## Tying it all together: completion 529## Tying it all together: completion
530 530
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index dc367d1e0..97a11a01e 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -192,7 +192,7 @@ impl TidyDocs {
192 } 192 }
193 193
194 let poorly_documented = [ 194 let poorly_documented = [
195 "ra_hir", 195 "hir",
196 "hir_expand", 196 "hir_expand",
197 "ra_ide", 197 "ra_ide",
198 "mbe", 198 "mbe",
@@ -201,7 +201,7 @@ impl TidyDocs {
201 "project_model", 201 "project_model",
202 "syntax", 202 "syntax",
203 "tt", 203 "tt",
204 "ra_hir_ty", 204 "hir_ty",
205 ]; 205 ];
206 206
207 let mut has_fixmes = 207 let mut has_fixmes =