Repository: rust-analyzer/rust-analyzer
Pull request #2745 (2020-01-04 09:58:18)

remove unused file


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 9187a913bd..2d1856d99c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -442,7 +442,7 @@ name = "humantime"
 version = "1.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -836,7 +836,7 @@ dependencies = [
  "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -845,7 +845,7 @@ dependencies = [
 
 [[package]]
 name = "quick-error"
-version = "1.2.3"
+version = "1.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -1868,7 +1868,7 @@ dependencies = [
 "checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
 "checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc"
 "checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f"
-"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
+"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
 "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
 "checksum ra_vfs 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bc898f237e4b4498959ae0100c688793a23e77624d44ef710ba70094217f98e0"
 "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index cc42068a10..488f74cfb1 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -25,7 +25,6 @@ use hir_ty::{
     TraitEnvironment, Ty, TyDefId, TypeCtor, TypeWalk,
 };
 use ra_db::{CrateId, Edition, FileId};
-use ra_prof::profile;
 use ra_syntax::ast;
 
 use crate::{
@@ -190,7 +189,6 @@ impl Module {
     }
 
     pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) {
-        let _p = profile("Module::diagnostics");
         db.crate_def_map(self.id.krate).add_diagnostics(db, self.id.local_id, sink);
         for decl in self.declarations(db) {
             match decl {
@@ -509,7 +507,6 @@ impl Function {
     }
 
     pub fn diagnostics(self, db: &impl HirDatabase, sink: &mut DiagnosticSink) {
-        let _p = profile("Function::diagnostics");
         let infer = db.infer(self.id.into());
         infer.add_diagnostics(db, self.id, sink);
         let mut validator = ExprValidator::new(self.id, infer, sink);
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index e6079b88da..f5ffd64fa7 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -1,21 +1,21 @@
 //! FIXME: write short doc here
 
 pub use hir_def::db::{
-    BodyQuery, BodyWithSourceMapQuery, ComputeCrateDefMapQuery, ConstDataQuery,
-    CrateLangItemsQuery, DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery,
-    ExprScopesQuery, FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase,
-    InternDatabaseStorage, LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, StaticDataQuery,
-    StructDataQuery, TraitDataQuery, TypeAliasDataQuery,
+    BodyQuery, BodyWithSourceMapQuery, ConstDataQuery, CrateDefMapQuery, CrateLangItemsQuery,
+    DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, ExprScopesQuery,
+    FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, InternDatabaseStorage,
+    LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, StaticDataQuery, StructDataQuery,
+    TraitDataQuery, TypeAliasDataQuery,
 };
 pub use hir_expand::db::{
     AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery,
     ParseMacroQuery,
 };
 pub use hir_ty::db::{
-    AssociatedTyDataQuery, CallableItemSignatureQuery, DoInferQuery, FieldTypesQuery,
-    GenericDefaultsQuery, GenericPredicatesQuery, HirDatabase, HirDatabaseStorage, ImplDatumQuery,
-    ImplsForTraitQuery, ImplsInCrateQuery, StructDatumQuery, TraitDatumQuery, TraitSolveQuery,
-    TyQuery, ValueTyQuery,
+    AssociatedTyDataQuery, CallableItemSignatureQuery, FieldTypesQuery, GenericDefaultsQuery,
+    GenericPredicatesQuery, HirDatabase, HirDatabaseStorage, ImplDatumQuery, ImplsForTraitQuery,
+    ImplsInCrateQuery, InferQuery, StructDatumQuery, TraitDatumQuery, TraitSolveQuery, TyQuery,
+    ValueTyQuery,
 };
 
 #[test]
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs
index da273eb115..c55fd41110 100644
--- a/crates/ra_hir_def/src/db.rs
+++ b/crates/ra_hir_def/src/db.rs
@@ -3,7 +3,6 @@ use std::sync::Arc;
 
 use hir_expand::{db::AstDatabase, HirFileId};
 use ra_db::{salsa, CrateId, SourceDatabase};
-use ra_prof::profile;
 use ra_syntax::SmolStr;
 
 use crate::{
@@ -47,12 +46,9 @@ pub trait DefDatabase: InternDatabase + AstDatabase {
     #[salsa::invoke(RawItems::raw_items_query)]
     fn raw_items(&self, file_id: HirFileId) -> Arc<RawItems>;
 
-    #[salsa::transparent]
+    #[salsa::invoke(CrateDefMap::crate_def_map_query)]
     fn crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>;
 
-    #[salsa::invoke(CrateDefMap::compute_crate_def_map_query)]
-    fn compute_crate_def_map(&self, krate: CrateId) -> Arc<CrateDefMap>;
-
     #[salsa::invoke(StructData::struct_data_query)]
     fn struct_data(&self, id: StructId) -> Arc<StructData>;
     #[salsa::invoke(StructData::union_data_query)]
@@ -108,8 +104,3 @@ pub trait DefDatabase: InternDatabase + AstDatabase {
     #[salsa::invoke(Documentation::documentation_query)]
     fn documentation(&self, def: AttrDefId) -> Option<Documentation>;
 }
-
-fn crate_def_map(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
-    let _p = profile("crate_def_map");
-    db.compute_crate_def_map(krate)
-}
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index 4d210eab12..5d4ca73a39 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -172,13 +172,13 @@ pub struct ModuleData {
 }
 
 impl CrateDefMap {
-    pub(crate) fn compute_crate_def_map_query(
+    pub(crate) fn crate_def_map_query(
         // Note that this doesn't have `+ AstDatabase`!
         // This gurantess that `CrateDefMap` is stable across reparses.
         db: &impl DefDatabase,
         krate: CrateId,
     ) -> Arc<CrateDefMap> {
-        let _p = profile("compute_crate_def_map");
+        let _p = profile("crate_def_map_query");
         let def_map = {
             let crate_graph = db.crate_graph();
             let edition = crate_graph.edition(krate);
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 35b852ee21..8a22b05859 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -45,6 +45,7 @@ pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> C
         // If the dependency defines a prelude, we overwrite an already defined
         // prelude. This is necessary to import the "std" prelude if a crate
         // depends on both "core" and "std".
+        let dep_def_map = db.crate_def_map(dep.crate_id);
         if dep_def_map.prelude.is_some() {
             def_map.prelude = dep_def_map.prelude;
         }
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index eb521c7a06..d52f65b836 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -7,7 +7,6 @@ use hir_def::{
 };
 use ra_arena::map::ArenaMap;
 use ra_db::{salsa, CrateId};
-use ra_prof::profile;
 
 use crate::{
     method_resolution::CrateImplBlocks,
@@ -19,12 +18,9 @@ use crate::{
 #[salsa::query_group(HirDatabaseStorage)]
 #[salsa::requires(salsa::Database)]
 pub trait HirDatabase: DefDatabase {
-    #[salsa::transparent]
+    #[salsa::invoke(crate::infer_query)]
     fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
 
-    #[salsa::invoke(crate::do_infer_query)]
-    fn do_infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
-
     #[salsa::invoke(crate::lower::ty_query)]
     #[salsa::cycle(crate::lower::ty_recover)]
     fn ty(&self, def: TyDefId) -> Ty;
@@ -108,11 +104,6 @@ pub trait HirDatabase: DefDatabase {
     ) -> Option<crate::traits::Solution>;
 }
 
-fn infer(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
-    let _p = profile("infer");
-    db.do_infer(def)
-}
-
 #[test]
 fn hir_database_is_object_safe() {
     fn _assert_object_safe(_: &dyn HirDatabase) {}
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs
index e2eda3134b..37e69599da 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/ra_hir_ty/src/infer.rs
@@ -62,8 +62,8 @@ mod pat;
 mod coerce;
 
 /// The entry point of type inference.
-pub fn do_infer_query(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
-    let _p = profile("do_infer");
+pub fn infer_query(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
+    let _p = profile("infer_query");
     let resolver = def.resolver(db);
     let mut ctx = InferenceContext::new(db, def, resolver);
 
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index d63f862dc9..55b6dd836c 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -58,7 +58,7 @@ use crate::{
 use display::{HirDisplay, HirFormatter};
 
 pub use autoderef::autoderef;
-pub use infer::{do_infer_query, InferTy, InferenceResult};
+pub use infer::{infer_query, InferTy, InferenceResult};
 pub use lower::CallableDef;
 pub use lower::{callable_item_sig, TyDefId, ValueTyDefId};
 pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index 2c2ecee9cc..af3db2e1d7 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -331,7 +331,7 @@ pub(super) fn substs_from_path_segment(
     if let Some(generic_args) = &segment.args_and_bindings {
         // if args are provided, it should be all of them, but we can't rely on that
         let self_param_correction = if add_self_param { 1 } else { 0 };
-        let child_len = child_len - self_param_correction;
+        let child_len = child_len + self_param_correction;
         for arg in generic_args.args.iter().take(child_len) {
             match arg {
                 GenericArg::Type(type_ref) => {
diff --git a/crates/ra_ide/src/change.rs b/crates/ra_ide/src/change.rs
index f92950b71d..387a9cafb6 100644
--- a/crates/ra_ide/src/change.rs
+++ b/crates/ra_ide/src/change.rs
@@ -273,7 +273,7 @@ impl RootDatabase {
         self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep);
 
         self.query(hir::db::ExprScopesQuery).sweep(sweep);
-        self.query(hir::db::DoInferQuery).sweep(sweep);
+        self.query(hir::db::InferQuery).sweep(sweep);
         self.query(hir::db::BodyQuery).sweep(sweep);
     }
 
@@ -309,7 +309,7 @@ impl RootDatabase {
             hir::db::EnumDataQuery
             hir::db::TraitDataQuery
             hir::db::RawItemsQuery
-            hir::db::ComputeCrateDefMapQuery
+            hir::db::CrateDefMapQuery
             hir::db::GenericParamsQuery
             hir::db::FunctionDataQuery
             hir::db::TypeAliasDataQuery
@@ -320,7 +320,7 @@ impl RootDatabase {
             hir::db::LangItemQuery
             hir::db::DocumentationQuery
             hir::db::ExprScopesQuery
-            hir::db::DoInferQuery
+            hir::db::InferQuery
             hir::db::TyQuery
             hir::db::ValueTyQuery
             hir::db::FieldTypesQuery
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
deleted file mode 100644
index 47446a878c..0000000000
--- a/crates/ra_syntax/src/grammar.ron
+++ /dev/null
@@ -1,6 +0,0 @@
-// Stores definitions which must be used in multiple places
-// See `cargo xtask codegen` (defined in xtasks/src/main.rs)
-Grammar(
-    ast: {
-    },
-)


Test patch:
diff --git a/crates/ra_cargo_watch/src/conv/test.rs b/crates/ra_cargo_watch/src/conv/test.rs
index 6b86525b83..f77ef1b4d1 100644
--- a/crates/ra_cargo_watch/src/conv/test.rs
+++ b/crates/ra_cargo_watch/src/conv/test.rs
@@ -1,9 +1,7 @@
 //! This module contains the large and verbose snapshot tests for the
 //! conversions between `cargo check` json and LSP diagnostics.
-#[cfg(not(windows))]
 use crate::*;
 
-#[cfg(not(windows))]
 fn parse_diagnostic(val: &str) -> cargo_metadata::diagnostic::Diagnostic {
     serde_json::from_str::<cargo_metadata::diagnostic::Diagnostic>(val).unwrap()
 }
diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs
index 13c5f62e40..8b3aa85642 100644
--- a/crates/ra_hir_ty/src/tests/regression.rs
+++ b/crates/ra_hir_ty/src/tests/regression.rs
@@ -365,20 +365,3 @@ fn issue_2669() {
     "###
     )
 }
-
-#[test]
-fn issue_2705() {
-    assert_snapshot!(
-        infer(r#"
-trait Trait {}
-fn test() {
-    <Trait<u32>>::foo()
-}
-"#),
-        @r###"
-    [26; 53) '{     ...oo() }': ()
-    [32; 49) '<Trait...>::foo': {unknown}
-    [32; 51) '<Trait...:foo()': ()
-    "###
-    );
-}