aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock22
-rw-r--r--README.md3
-rw-r--r--crates/ra_hir/Cargo.toml2
-rw-r--r--crates/ra_hir/src/db.rs8
-rw-r--r--crates/ra_hir/src/mock.rs6
-rw-r--r--crates/ra_hir/src/name.rs2
-rw-r--r--crates/ra_hir/src/nameres/tests.rs286
-rw-r--r--crates/ra_hir/src/nameres/tests/globs.rs76
-rw-r--r--crates/ra_hir/src/nameres/tests/macros.rs54
-rw-r--r--crates/ra_hir/src/ty.rs2
-rw-r--r--crates/ra_hir/src/ty/infer.rs4
-rw-r--r--crates/ra_hir/src/ty/traits.rs8
-rw-r--r--crates/ra_ide_api/Cargo.toml2
-rw-r--r--crates/ra_prof/src/lib.rs1
-rw-r--r--crates/ra_syntax/Cargo.toml2
15 files changed, 238 insertions, 240 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1e2fc7851..02adbe0a9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -257,7 +257,7 @@ dependencies = [
257 "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 257 "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
258 "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 258 "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
259 "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", 259 "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
260 "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 260 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
261 "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 261 "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
262 "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 262 "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
263 "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 263 "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -551,7 +551,7 @@ dependencies = [
551 "console 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", 551 "console 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
552 "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 552 "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
553 "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", 553 "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
554 "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 554 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
555 "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 555 "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
556] 556]
557 557
@@ -575,7 +575,7 @@ dependencies = [
575 575
576[[package]] 576[[package]]
577name = "insta" 577name = "insta"
578version = "0.7.4" 578version = "0.8.1"
579source = "registry+https://github.com/rust-lang/crates.io-index" 579source = "registry+https://github.com/rust-lang/crates.io-index"
580dependencies = [ 580dependencies = [
581 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 581 "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1114,7 +1114,7 @@ dependencies = [
1114 "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)", 1114 "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)",
1115 "ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 1115 "ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
1116 "flexi_logger 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", 1116 "flexi_logger 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)",
1117 "insta 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", 1117 "insta 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
1118 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 1118 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
1119 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 1119 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1120 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 1120 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1134,7 +1134,7 @@ name = "ra_ide_api"
1134version = "0.1.0" 1134version = "0.1.0"
1135dependencies = [ 1135dependencies = [
1136 "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 1136 "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
1137 "insta 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", 1137 "insta 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
1138 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 1138 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
1139 "jemalloc-ctl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 1139 "jemalloc-ctl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
1140 "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", 1140 "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1242,7 +1242,7 @@ dependencies = [
1242 "ra_parser 0.1.0", 1242 "ra_parser 0.1.0",
1243 "ra_text_edit 0.1.0", 1243 "ra_text_edit 0.1.0",
1244 "rowan 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", 1244 "rowan 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
1245 "smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 1245 "smol_str 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
1246 "test_utils 0.1.0", 1246 "test_utils 0.1.0",
1247 "text_unit 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 1247 "text_unit 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
1248 "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1248 "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1262,7 +1262,7 @@ dependencies = [
1262name = "ra_tt" 1262name = "ra_tt"
1263version = "0.1.0" 1263version = "0.1.0"
1264dependencies = [ 1264dependencies = [
1265 "smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 1265 "smol_str 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
1266] 1266]
1267 1267
1268[[package]] 1268[[package]]
@@ -1467,7 +1467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1467dependencies = [ 1467dependencies = [
1468 "colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 1468 "colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
1469 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 1469 "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
1470 "smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 1470 "smol_str 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
1471 "text_unit 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 1471 "text_unit 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
1472] 1472]
1473 1473
@@ -1625,7 +1625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1625 1625
1626[[package]] 1626[[package]]
1627name = "smol_str" 1627name = "smol_str"
1628version = "0.1.10" 1628version = "0.1.11"
1629source = "registry+https://github.com/rust-lang/crates.io-index" 1629source = "registry+https://github.com/rust-lang/crates.io-index"
1630dependencies = [ 1630dependencies = [
1631 "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", 1631 "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2087,7 +2087,7 @@ dependencies = [
2087"checksum indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c60da1c9abea75996b70a931bba6c750730399005b61ccd853cee50ef3d0d0c" 2087"checksum indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c60da1c9abea75996b70a931bba6c750730399005b61ccd853cee50ef3d0d0c"
2088"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" 2088"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718"
2089"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" 2089"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0"
2090"checksum insta 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "03e7d88a87d342ce8bd698516151be43e6eb2e84b683db528696cb4a382f734a" 2090"checksum insta 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8bbbb69ec4557c37b2bf4d525d106d828e0c2fbd6c44bc98cd3798da13c73b9f"
2091"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" 2091"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
2092"checksum itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d" 2092"checksum itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0d47946d458e94a1b7bcabbf6521ea7c037062c81f534615abcad76e84d4970d"
2093"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" 2093"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
@@ -2181,7 +2181,7 @@ dependencies = [
2181"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" 2181"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
2182"checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" 2182"checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373"
2183"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" 2183"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be"
2184"checksum smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d077b3367211e9c6e2e012fb804c444e0d80ab5a51ae4137739b58e6446dcaef" 2184"checksum smol_str 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e6507d018aa8dfcaa08aaab587605591cd2109df66a921486a2220e2daf9fa29"
2185"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" 2185"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
2186"checksum stacker 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb79482f57cf598af52094ec4cc3b3c42499d3ce5bd426f2ac41515b7e57404b" 2186"checksum stacker 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb79482f57cf598af52094ec4cc3b3c42499d3ce5bd426f2ac41515b7e57404b"
2187"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 2187"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
diff --git a/README.md b/README.md
index 8df991246..1dd0fec6c 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,8 @@ https://github.com/rust-lang/compiler-team/tree/master/working-groups/rls-2.0
11 11
12Work on the Rust Analyzer is sponsored by 12Work on the Rust Analyzer is sponsored by
13 13
14[![Ferrous Systems](https://ferrous-systems.com/images/ferrous-logo-text.svg)](https://ferrous-systems.com/) 14- [![Ferrous Systems](https://ferrous-systems.com/images/ferrous-logo-text.svg)](https://ferrous-systems.com/)
15- [Mozilla](https://www.mozilla.org/en-US/)
15 16
16## Language Server Quick Start 17## Language Server Quick Start
17 18
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml
index 68ffcb2e9..cb4a8c3e3 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/ra_hir/Cargo.toml
@@ -27,4 +27,4 @@ chalk-ir = { git = "https://github.com/rust-lang/chalk.git" }
27 27
28[dev-dependencies] 28[dev-dependencies]
29flexi_logger = "0.11.0" 29flexi_logger = "0.11.0"
30insta = "0.7.0" 30insta = "0.8.1"
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index bda02d3cc..11cdf9c34 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -126,7 +126,7 @@ pub trait HirDatabase: DefDatabase {
126 #[salsa::invoke(ExprScopes::expr_scopes_query)] 126 #[salsa::invoke(ExprScopes::expr_scopes_query)]
127 fn expr_scopes(&self, def: DefWithBody) -> Arc<ExprScopes>; 127 fn expr_scopes(&self, def: DefWithBody) -> Arc<ExprScopes>;
128 128
129 #[salsa::invoke(crate::ty::infer)] 129 #[salsa::invoke(crate::ty::infer_query)]
130 fn infer(&self, def: DefWithBody) -> Arc<InferenceResult>; 130 fn infer(&self, def: DefWithBody) -> Arc<InferenceResult>;
131 131
132 #[salsa::invoke(crate::ty::type_for_def)] 132 #[salsa::invoke(crate::ty::type_for_def)]
@@ -156,7 +156,7 @@ pub trait HirDatabase: DefDatabase {
156 #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)] 156 #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)]
157 fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>; 157 fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>;
158 158
159 #[salsa::invoke(crate::ty::traits::impls_for_trait)] 159 #[salsa::invoke(crate::ty::traits::impls_for_trait_query)]
160 fn impls_for_trait(&self, krate: Crate, trait_: Trait) -> Arc<[ImplBlock]>; 160 fn impls_for_trait(&self, krate: Crate, trait_: Trait) -> Arc<[ImplBlock]>;
161 161
162 /// This provides the Chalk trait solver instance. Because Chalk always 162 /// This provides the Chalk trait solver instance. Because Chalk always
@@ -164,11 +164,11 @@ pub trait HirDatabase: DefDatabase {
164 /// because Chalk does its own internal caching, the solver is wrapped in a 164 /// because Chalk does its own internal caching, the solver is wrapped in a
165 /// Mutex and the query is marked volatile, to make sure the cached state is 165 /// Mutex and the query is marked volatile, to make sure the cached state is
166 /// thrown away when input facts change. 166 /// thrown away when input facts change.
167 #[salsa::invoke(crate::ty::traits::solver)] 167 #[salsa::invoke(crate::ty::traits::solver_query)]
168 #[salsa::volatile] 168 #[salsa::volatile]
169 fn solver(&self, krate: Crate) -> Arc<Mutex<crate::ty::traits::Solver>>; 169 fn solver(&self, krate: Crate) -> Arc<Mutex<crate::ty::traits::Solver>>;
170 170
171 #[salsa::invoke(crate::ty::traits::implements)] 171 #[salsa::invoke(crate::ty::traits::implements_query)]
172 fn implements( 172 fn implements(
173 &self, 173 &self,
174 krate: Crate, 174 krate: Crate,
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index fa5882dea..b84cb7503 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -236,7 +236,7 @@ impl MockDatabase {
236} 236}
237 237
238#[derive(Default)] 238#[derive(Default)]
239pub struct CrateGraphFixture(pub FxHashMap<String, (String, Edition, Vec<String>)>); 239pub struct CrateGraphFixture(pub Vec<(String, (String, Edition, Vec<String>))>);
240 240
241#[macro_export] 241#[macro_export]
242macro_rules! crate_graph { 242macro_rules! crate_graph {
@@ -246,10 +246,10 @@ macro_rules! crate_graph {
246 #[allow(unused_mut, unused_assignments)] 246 #[allow(unused_mut, unused_assignments)]
247 let mut edition = ra_db::Edition::Edition2018; 247 let mut edition = ra_db::Edition::Edition2018;
248 $(edition = ra_db::Edition::from_string($edition);)? 248 $(edition = ra_db::Edition::from_string($edition);)?
249 res.0.insert( 249 res.0.push((
250 $crate_name.to_string(), 250 $crate_name.to_string(),
251 ($crate_path.to_string(), edition, vec![$($dep.to_string()),*]) 251 ($crate_path.to_string(), edition, vec![$($dep.to_string()),*])
252 ); 252 ));
253 )* 253 )*
254 res 254 res
255 }} 255 }}
diff --git a/crates/ra_hir/src/name.rs b/crates/ra_hir/src/name.rs
index 9a999e66c..e3a82cf03 100644
--- a/crates/ra_hir/src/name.rs
+++ b/crates/ra_hir/src/name.rs
@@ -5,7 +5,7 @@ use ra_syntax::{ast, SmolStr};
5/// `Name` is a wrapper around string, which is used in hir for both references 5/// `Name` is a wrapper around string, which is used in hir for both references
6/// and declarations. In theory, names should also carry hygiene info, but we are 6/// and declarations. In theory, names should also carry hygiene info, but we are
7/// not there yet! 7/// not there yet!
8#[derive(Clone, PartialEq, Eq, Hash)] 8#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
9pub struct Name { 9pub struct Name {
10 text: SmolStr, 10 text: SmolStr,
11} 11}
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs
index 572bd1bf7..14c8ee50b 100644
--- a/crates/ra_hir/src/nameres/tests.rs
+++ b/crates/ra_hir/src/nameres/tests.rs
@@ -8,7 +8,11 @@ use ra_db::SourceDatabase;
8use test_utils::covers; 8use test_utils::covers;
9use insta::assert_snapshot_matches; 9use insta::assert_snapshot_matches;
10 10
11use crate::{Crate, mock::{MockDatabase, CrateGraphFixture}, nameres::Resolution}; 11use crate::{
12 Crate,
13 mock::{MockDatabase, CrateGraphFixture},
14 nameres::Resolution,
15};
12 16
13use super::*; 17use super::*;
14 18
@@ -25,12 +29,15 @@ fn compute_crate_def_map(fixture: &str, graph: Option<CrateGraphFixture>) -> Arc
25fn render_crate_def_map(map: &CrateDefMap) -> String { 29fn render_crate_def_map(map: &CrateDefMap) -> String {
26 let mut buf = String::new(); 30 let mut buf = String::new();
27 go(&mut buf, map, "\ncrate", map.root); 31 go(&mut buf, map, "\ncrate", map.root);
28 return buf; 32 return buf.trim().to_string();
29 33
30 fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: CrateModuleId) { 34 fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: CrateModuleId) {
31 *buf += path; 35 *buf += path;
32 *buf += "\n"; 36 *buf += "\n";
33 for (name, res) in map.modules[module].scope.items.iter() { 37
38 let mut entries = map.modules[module].scope.items.iter().collect::<Vec<_>>();
39 entries.sort_by_key(|(name, _)| *name);
40 for (name, res) in entries {
34 *buf += &format!("{}: {}\n", name, dump_resolution(res)) 41 *buf += &format!("{}: {}\n", name, dump_resolution(res))
35 } 42 }
36 for (name, child) in map.modules[module].children.iter() { 43 for (name, child) in map.modules[module].children.iter() {
@@ -54,8 +61,8 @@ fn def_map(fixtute: &str) -> String {
54 render_crate_def_map(&dm) 61 render_crate_def_map(&dm)
55} 62}
56 63
57fn def_map_with_crate_graph(fixtute: &str, graph: CrateGraphFixture) -> String { 64fn def_map_with_crate_graph(fixture: &str, graph: CrateGraphFixture) -> String {
58 let dm = compute_crate_def_map(fixtute, Some(graph)); 65 let dm = compute_crate_def_map(fixture, Some(graph));
59 render_crate_def_map(&dm) 66 render_crate_def_map(&dm)
60} 67}
61 68
@@ -79,21 +86,20 @@ fn crate_def_map_smoke_test() {
79 ", 86 ",
80 ); 87 );
81 assert_snapshot_matches!(map, @r###" 88 assert_snapshot_matches!(map, @r###"
82crate 89 ⋮crate
83V: t v 90 ⋮E: t
84E: t 91 ⋮S: t v
85foo: t 92 ⋮V: t v
86S: t v 93 ⋮foo: t
87 94
88crate::foo 95 ⋮crate::foo
89bar: t 96 ⋮bar: t
90f: v 97 ⋮f: v
91 98
92crate::foo::bar 99 ⋮crate::foo::bar
93Baz: t v 100 ⋮Baz: t v
94E: t 101 ⋮E: t
95"### 102 "###)
96 )
97} 103}
98 104
99#[test] 105#[test]
@@ -113,12 +119,12 @@ fn bogus_paths() {
113 ", 119 ",
114 ); 120 );
115 assert_snapshot_matches!(map, @r###" 121 assert_snapshot_matches!(map, @r###"
116crate 122crate
117foo: t 123 ⋮S: t v
118S: t v 124 ⋮foo: t
119 125
120crate::foo 126crate::foo
121"### 127 "###
122 ) 128 )
123} 129}
124 130
@@ -137,13 +143,13 @@ fn use_as() {
137 ); 143 );
138 assert_snapshot_matches!(map, 144 assert_snapshot_matches!(map,
139 @r###" 145 @r###"
140crate 146crate
141Foo: t v 147Foo: t v
142foo: t 148foo: t
143 149
144crate::foo 150crate::foo
145Baz: t v 151Baz: t v
146"### 152 "###
147 ); 153 );
148} 154}
149 155
@@ -164,21 +170,19 @@ fn use_trees() {
164 pub enum Quux {}; 170 pub enum Quux {};
165 ", 171 ",
166 ); 172 );
167 assert_snapshot_matches!(map, 173 assert_snapshot_matches!(map, @r###"
168 @r###" 174 ⋮crate
169crate 175 ⋮Baz: t v
170Quux: t 176 ⋮Quux: t
171Baz: t v 177 ⋮foo: t
172foo: t 178
173 179 ⋮crate::foo
174crate::foo 180 ⋮bar: t
175bar: t 181
176 182 ⋮crate::foo::bar
177crate::foo::bar 183 ⋮Baz: t v
178Quux: t 184 ⋮Quux: t
179Baz: t v 185 "###);
180"###
181 );
182} 186}
183 187
184#[test] 188#[test]
@@ -199,20 +203,18 @@ fn re_exports() {
199 pub struct Baz; 203 pub struct Baz;
200 ", 204 ",
201 ); 205 );
202 assert_snapshot_matches!(map, 206 assert_snapshot_matches!(map, @r###"
203 @r###" 207 ⋮crate
204crate 208 ⋮Baz: t v
205Baz: t v 209 ⋮foo: t
206foo: t 210
207 211 ⋮crate::foo
208crate::foo 212 ⋮Baz: t v
209bar: t 213 ⋮bar: t
210Baz: t v 214
211 215 ⋮crate::foo::bar
212crate::foo::bar 216 ⋮Baz: t v
213Baz: t v 217 "###);
214"###
215 );
216} 218}
217 219
218#[test] 220#[test]
@@ -237,10 +239,10 @@ fn std_prelude() {
237 }, 239 },
238 ); 240 );
239 assert_snapshot_matches!(map, @r###" 241 assert_snapshot_matches!(map, @r###"
240crate 242crate
241Bar: t v 243Bar: t v
242Baz: t v 244Baz: t v
243"###); 245 "###);
244} 246}
245 247
246#[test] 248#[test]
@@ -254,10 +256,10 @@ fn can_import_enum_variant() {
254 ", 256 ",
255 ); 257 );
256 assert_snapshot_matches!(map, @r###" 258 assert_snapshot_matches!(map, @r###"
257crate 259crate
258V: t v 260 ⋮E: t
259E: t 261 ⋮V: t v
260"### 262 "###
261 ); 263 );
262} 264}
263 265
@@ -285,20 +287,18 @@ fn edition_2015_imports() {
285 }, 287 },
286 ); 288 );
287 289
288 assert_snapshot_matches!(map, 290 assert_snapshot_matches!(map, @r###"
289 @r###" 291 ⋮crate
290crate 292 ⋮bar: t
291bar: t 293 ⋮foo: t
292foo: t 294
293 295 ⋮crate::bar
294crate::bar 296 ⋮Bar: t v
295Bar: t v 297
296 298 ⋮crate::foo
297crate::foo 299 ⋮Bar: t v
298FromLib: t v 300 ⋮FromLib: t v
299Bar: t v 301 "###);
300"###
301 );
302} 302}
303 303
304#[test] 304#[test]
@@ -317,16 +317,14 @@ fn module_resolution_works_for_non_standard_filenames() {
317 }, 317 },
318 ); 318 );
319 319
320 assert_snapshot_matches!(map, 320 assert_snapshot_matches!(map, @r###"
321 @r###" 321 ⋮crate
322crate 322 ⋮Bar: t v
323Bar: t v 323 ⋮foo: t
324foo: t 324
325 325 ⋮crate::foo
326crate::foo 326 ⋮Bar: t v
327Bar: t v 327 "###);
328"###
329 );
330} 328}
331 329
332#[test] 330#[test]
@@ -348,12 +346,10 @@ fn name_res_works_for_broken_modules() {
348 pub struct Baz; 346 pub struct Baz;
349 ", 347 ",
350 ); 348 );
351 assert_snapshot_matches!(map, 349 assert_snapshot_matches!(map, @r###"
352 @r###" 350 ⋮crate
353crate 351 ⋮Baz: _
354Baz: _ 352 "###);
355"###
356 );
357} 353}
358 354
359#[test] 355#[test]
@@ -369,19 +365,17 @@ fn item_map_using_self() {
369 pub struct Baz; 365 pub struct Baz;
370 ", 366 ",
371 ); 367 );
372 assert_snapshot_matches!(map, 368 assert_snapshot_matches!(map, @r###"
373 @r###" 369 ⋮crate
374crate 370 ⋮Baz: t v
375Baz: t v 371 ⋮foo: t
376foo: t 372
377 373 ⋮crate::foo
378crate::foo 374 ⋮bar: t
379bar: t 375
380 376 ⋮crate::foo::bar
381crate::foo::bar 377 ⋮Baz: t v
382Baz: t v 378 "###);
383"###
384 );
385} 379}
386 380
387#[test] 381#[test]
@@ -400,12 +394,10 @@ fn item_map_across_crates() {
400 }, 394 },
401 ); 395 );
402 396
403 assert_snapshot_matches!(map, 397 assert_snapshot_matches!(map, @r###"
404 @r###" 398 ⋮crate
405crate 399 ⋮Baz: t v
406Baz: t v 400 "###);
407"###
408 );
409} 401}
410 402
411#[test] 403#[test]
@@ -430,12 +422,14 @@ fn extern_crate_rename() {
430 }, 422 },
431 ); 423 );
432 424
433 assert_snapshot_matches!(map, 425 assert_snapshot_matches!(map, @r###"
434 @r###" 426 ⋮crate
435crate 427 ⋮alloc_crate: t
436Arc: t v 428 ⋮sync: t
437"### 429
438 ); 430 ⋮crate::sync
431 ⋮Arc: t v
432 "###);
439} 433}
440 434
441#[test] 435#[test]
@@ -462,9 +456,13 @@ fn extern_crate_rename_2015_edition() {
462 456
463 assert_snapshot_matches!(map, 457 assert_snapshot_matches!(map,
464 @r###" 458 @r###"
465crate 459 ⋮crate
466Arc: t v 460 ⋮alloc_crate: t
467"### 461 ⋮sync: t
462
463 ⋮crate::sync
464 ⋮Arc: t v
465 "###
468 ); 466 );
469} 467}
470 468
@@ -490,12 +488,10 @@ fn import_across_source_roots() {
490 }, 488 },
491 ); 489 );
492 490
493 assert_snapshot_matches!(map, 491 assert_snapshot_matches!(map, @r###"
494 @r###" 492 ⋮crate
495crate 493 ⋮C: t v
496C: t v 494 "###);
497"###
498 );
499} 495}
500 496
501#[test] 497#[test]
@@ -519,12 +515,10 @@ fn reexport_across_crates() {
519 }, 515 },
520 ); 516 );
521 517
522 assert_snapshot_matches!(map, 518 assert_snapshot_matches!(map, @r###"
523 @r###" 519 ⋮crate
524crate 520 ⋮Baz: t v
525Baz: t v 521 "###);
526"###
527 );
528} 522}
529 523
530#[test] 524#[test]
@@ -544,13 +538,11 @@ fn values_dont_shadow_extern_crates() {
544 }, 538 },
545 ); 539 );
546 540
547 assert_snapshot_matches!(map, 541 assert_snapshot_matches!(map, @r###"
548 @r###" 542 ⋮crate
549crate 543 ⋮Bar: t v
550Bar: t v 544 ⋮foo: v
551foo: v 545 "###);
552"###
553 );
554} 546}
555 547
556#[test] 548#[test]
diff --git a/crates/ra_hir/src/nameres/tests/globs.rs b/crates/ra_hir/src/nameres/tests/globs.rs
index 6e50c7ff6..e1519ca6b 100644
--- a/crates/ra_hir/src/nameres/tests/globs.rs
+++ b/crates/ra_hir/src/nameres/tests/globs.rs
@@ -18,20 +18,20 @@ fn glob_1() {
18 ", 18 ",
19 ); 19 );
20 assert_snapshot_matches!(map, @r###" 20 assert_snapshot_matches!(map, @r###"
21crate 21crate
22bar: t 22 ⋮Baz: t v
23Foo: t v 23Foo: t v
24Baz: t v 24 ⋮bar: t
25foo: t 25foo: t
26 26
27crate::foo 27crate::foo
28bar: t 28 ⋮Baz: t v
29Foo: t v 29Foo: t v
30Baz: t v 30 ⋮bar: t
31 31
32crate::foo::bar 32crate::foo::bar
33Baz: t v 33Baz: t v
34"### 34 "###
35 ); 35 );
36} 36}
37 37
@@ -54,22 +54,22 @@ fn glob_2() {
54 ", 54 ",
55 ); 55 );
56 assert_snapshot_matches!(map, @r###" 56 assert_snapshot_matches!(map, @r###"
57crate 57crate
58bar: t 58 ⋮Baz: t v
59Foo: t v 59Foo: t v
60Baz: t v 60 ⋮bar: t
61foo: t 61foo: t
62 62
63crate::foo 63crate::foo
64bar: t 64 ⋮Baz: t v
65Foo: t v 65Foo: t v
66Baz: t v 66 ⋮bar: t
67 67
68crate::foo::bar 68crate::foo::bar
69bar: t 69 ⋮Baz: t v
70Foo: t v 70Foo: t v
71Baz: t v 71 ⋮bar: t
72"### 72 "###
73 ); 73 );
74} 74}
75 75
@@ -90,9 +90,9 @@ fn glob_across_crates() {
90 }, 90 },
91 ); 91 );
92 assert_snapshot_matches!(map, @r###" 92 assert_snapshot_matches!(map, @r###"
93crate 93crate
94Baz: t v 94Baz: t v
95"### 95 "###
96 ); 96 );
97} 97}
98 98
@@ -109,10 +109,10 @@ fn glob_enum() {
109 ", 109 ",
110 ); 110 );
111 assert_snapshot_matches!(map, @r###" 111 assert_snapshot_matches!(map, @r###"
112crate 112crate
113Foo: t 113 ⋮Bar: t v
114Bar: t v 114Baz: t v
115Baz: t v 115 ⋮Foo: t
116"### 116 "###
117 ); 117 );
118} 118}
diff --git a/crates/ra_hir/src/nameres/tests/macros.rs b/crates/ra_hir/src/nameres/tests/macros.rs
index 8781b026b..f7ca380ad 100644
--- a/crates/ra_hir/src/nameres/tests/macros.rs
+++ b/crates/ra_hir/src/nameres/tests/macros.rs
@@ -18,14 +18,14 @@ fn macro_rules_are_globally_visible() {
18 ", 18 ",
19 ); 19 );
20 assert_snapshot_matches!(map, @r###" 20 assert_snapshot_matches!(map, @r###"
21crate 21crate
22nested: t 22 ⋮Foo: t v
23Foo: t v 23 ⋮nested: t
24 24
25crate::nested 25crate::nested
26Bar: t v 26Bar: t v
27Baz: t v 27Baz: t v
28"###); 28 "###);
29} 29}
30 30
31#[test] 31#[test]
@@ -45,15 +45,15 @@ fn macro_rules_can_define_modules() {
45 ", 45 ",
46 ); 46 );
47 assert_snapshot_matches!(map, @r###" 47 assert_snapshot_matches!(map, @r###"
48crate 48crate
49n1: t 49n1: t
50 50
51crate::n1 51crate::n1
52n2: t 52n2: t
53 53
54crate::n1::n2 54crate::n1::n2
55X: t v 55X: t v
56"###); 56 "###);
57} 57}
58 58
59#[test] 59#[test]
@@ -81,14 +81,14 @@ fn macro_rules_from_other_crates_are_visible() {
81 }, 81 },
82 ); 82 );
83 assert_snapshot_matches!(map, @r###" 83 assert_snapshot_matches!(map, @r###"
84crate 84crate
85bar: t 85 ⋮Bar: t v
86Foo: t v 86Foo: t v
87Bar: t v 87 ⋮bar: t
88 88
89crate::bar 89crate::bar
90bar: t 90 ⋮Bar: t v
91Foo: t v 91Foo: t v
92Bar: t v 92 ⋮bar: t
93"###); 93 "###);
94} 94}
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 9a65bf567..3679a2242 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -20,7 +20,7 @@ use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait, GenericP
20use display::{HirDisplay, HirFormatter}; 20use display::{HirDisplay, HirFormatter};
21 21
22pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig, generic_predicates, generic_defaults}; 22pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig, generic_predicates, generic_defaults};
23pub(crate) use infer::{infer, InferenceResult, InferTy}; 23pub(crate) use infer::{infer_query, InferenceResult, InferTy};
24pub use lower::CallableDef; 24pub use lower::CallableDef;
25 25
26/// A type constructor or type name: this might be something like the primitive 26/// A type constructor or type name: this might be something like the primitive
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 1e7d97f51..a48272981 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -23,6 +23,7 @@ use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError};
23use rustc_hash::FxHashMap; 23use rustc_hash::FxHashMap;
24 24
25use ra_arena::map::ArenaMap; 25use ra_arena::map::ArenaMap;
26use ra_prof::profile;
26use test_utils::tested_by; 27use test_utils::tested_by;
27 28
28use crate::{ 29use crate::{
@@ -51,7 +52,8 @@ use super::{
51mod unify; 52mod unify;
52 53
53/// The entry point of type inference. 54/// The entry point of type inference.
54pub fn infer(db: &impl HirDatabase, def: DefWithBody) -> Arc<InferenceResult> { 55pub fn infer_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<InferenceResult> {
56 let _p = profile("infer_query");
55 db.check_canceled(); 57 db.check_canceled();
56 let body = def.body(db); 58 let body = def.body(db);
57 let resolver = def.resolver(db); 59 let resolver = def.resolver(db);
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs
index 7de04c044..f39749cab 100644
--- a/crates/ra_hir/src/ty/traits.rs
+++ b/crates/ra_hir/src/ty/traits.rs
@@ -4,6 +4,7 @@ use std::sync::{Arc, Mutex};
4use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
5use log::debug; 5use log::debug;
6use chalk_ir::cast::Cast; 6use chalk_ir::cast::Cast;
7use ra_prof::profile;
7 8
8use crate::{Crate, Trait, db::HirDatabase, ImplBlock}; 9use crate::{Crate, Trait, db::HirDatabase, ImplBlock};
9use super::{TraitRef, Ty, Canonical}; 10use super::{TraitRef, Ty, Canonical};
@@ -25,7 +26,7 @@ struct ChalkContext<'a, DB> {
25 krate: Crate, 26 krate: Crate,
26} 27}
27 28
28pub(crate) fn solver(_db: &impl HirDatabase, _krate: Crate) -> Arc<Mutex<Solver>> { 29pub(crate) fn solver_query(_db: &impl HirDatabase, _krate: Crate) -> Arc<Mutex<Solver>> {
29 // krate parameter is just so we cache a unique solver per crate 30 // krate parameter is just so we cache a unique solver per crate
30 let solver_choice = chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE }; 31 let solver_choice = chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE };
31 debug!("Creating new solver for crate {:?}", _krate); 32 debug!("Creating new solver for crate {:?}", _krate);
@@ -33,7 +34,7 @@ pub(crate) fn solver(_db: &impl HirDatabase, _krate: Crate) -> Arc<Mutex<Solver>
33} 34}
34 35
35/// Collects impls for the given trait in the whole dependency tree of `krate`. 36/// Collects impls for the given trait in the whole dependency tree of `krate`.
36pub(crate) fn impls_for_trait( 37pub(crate) fn impls_for_trait_query(
37 db: &impl HirDatabase, 38 db: &impl HirDatabase,
38 krate: Crate, 39 krate: Crate,
39 trait_: Trait, 40 trait_: Trait,
@@ -76,11 +77,12 @@ pub enum Obligation {
76} 77}
77 78
78/// Check using Chalk whether trait is implemented for given parameters including `Self` type. 79/// Check using Chalk whether trait is implemented for given parameters including `Self` type.
79pub(crate) fn implements( 80pub(crate) fn implements_query(
80 db: &impl HirDatabase, 81 db: &impl HirDatabase,
81 krate: Crate, 82 krate: Crate,
82 trait_ref: Canonical<TraitRef>, 83 trait_ref: Canonical<TraitRef>,
83) -> Option<Solution> { 84) -> Option<Solution> {
85 let _p = profile("implements_query");
84 let goal: chalk_ir::Goal = trait_ref.value.to_chalk(db).cast(); 86 let goal: chalk_ir::Goal = trait_ref.value.to_chalk(db).cast();
85 debug!("goal: {:?}", goal); 87 debug!("goal: {:?}", goal);
86 let env = chalk_ir::Environment::new(); 88 let env = chalk_ir::Environment::new();
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml
index 333706c1a..d399d5e2e 100644
--- a/crates/ra_ide_api/Cargo.toml
+++ b/crates/ra_ide_api/Cargo.toml
@@ -29,7 +29,7 @@ test_utils = { path = "../test_utils" }
29ra_assists = { path = "../ra_assists" } 29ra_assists = { path = "../ra_assists" }
30 30
31[dev-dependencies] 31[dev-dependencies]
32insta = "0.7.0" 32insta = "0.8.1"
33 33
34[dev-dependencies.proptest] 34[dev-dependencies.proptest]
35version = "0.9.0" 35version = "0.9.0"
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index e56446c9f..61f2226d7 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -198,6 +198,7 @@ fn print(lvl: usize, msgs: &[Message], out: &mut impl Write) {
198 if l != lvl { 198 if l != lvl {
199 continue; 199 continue;
200 } 200 }
201
201 writeln!(out, "{} {:6}ms - {}", indent, dur.as_millis(), msg) 202 writeln!(out, "{} {:6}ms - {}", indent, dur.as_millis(), msg)
202 .expect("printing profiling info to stdout"); 203 .expect("printing profiling info to stdout");
203 204
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml
index 2e521183c..082bc5253 100644
--- a/crates/ra_syntax/Cargo.toml
+++ b/crates/ra_syntax/Cargo.toml
@@ -18,7 +18,7 @@ rowan = "0.5.0"
18# ideally, `serde` should be enabled by `ra_lsp_server`, but we enable it here 18# ideally, `serde` should be enabled by `ra_lsp_server`, but we enable it here
19# to reduce number of compilations 19# to reduce number of compilations
20text_unit = { version = "0.1.8", features = ["serde"] } 20text_unit = { version = "0.1.8", features = ["serde"] }
21smol_str = { version = "0.1.9", features = ["serde"] } 21smol_str = { version = "0.1.11", features = ["serde"] }
22 22
23ra_text_edit = { path = "../ra_text_edit" } 23ra_text_edit = { path = "../ra_text_edit" }
24ra_parser = { path = "../ra_parser" } 24ra_parser = { path = "../ra_parser" }