remove FnId
This commit is contained in:
parent
efb63a7666
commit
dddbac6877
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -688,7 +688,7 @@ dependencies = [
|
|||||||
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=no-upgrade)",
|
"salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=fix-cancelation-maybe)",
|
||||||
"test_utils 0.1.0",
|
"test_utils 0.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -714,7 +714,7 @@ dependencies = [
|
|||||||
"ra_syntax 0.1.0",
|
"ra_syntax 0.1.0",
|
||||||
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=no-upgrade)",
|
"salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=fix-cancelation-maybe)",
|
||||||
"test_utils 0.1.0",
|
"test_utils 0.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -746,7 +746,7 @@ dependencies = [
|
|||||||
"ra_syntax 0.1.0",
|
"ra_syntax 0.1.0",
|
||||||
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=no-upgrade)",
|
"salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=fix-cancelation-maybe)",
|
||||||
"test_utils 0.1.0",
|
"test_utils 0.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1050,7 +1050,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "salsa"
|
name = "salsa"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
source = "git+https://github.com/matklad/salsa?branch=no-upgrade#1a7ae719af1601fda81186fb48bd100edd9cfb7f"
|
source = "git+https://github.com/matklad/salsa?branch=fix-cancelation-maybe#9f15af718f58c76a1280d457a113106baf7c20c5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1621,7 +1621,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c"
|
"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c"
|
||||||
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
|
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
|
||||||
"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
|
"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
|
||||||
"checksum salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=no-upgrade)" = "<none>"
|
"checksum salsa 0.8.0 (git+https://github.com/matklad/salsa?branch=fix-cancelation-maybe)" = "<none>"
|
||||||
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
|
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
|
||||||
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
|
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
|
||||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||||
|
@ -91,7 +91,6 @@ impl hir::db::HirDatabase {
|
|||||||
fn file_item() for hir::db::FileItemQuery;
|
fn file_item() for hir::db::FileItemQuery;
|
||||||
fn input_module_items() for hir::db::InputModuleItemsQuery;
|
fn input_module_items() for hir::db::InputModuleItemsQuery;
|
||||||
fn item_map() for hir::db::ItemMapQuery;
|
fn item_map() for hir::db::ItemMapQuery;
|
||||||
fn fn_syntax() for hir::db::FnSyntaxQuery;
|
|
||||||
fn submodules() for hir::db::SubmodulesQuery;
|
fn submodules() for hir::db::SubmodulesQuery;
|
||||||
fn infer() for hir::db::InferQuery;
|
fn infer() for hir::db::InferQuery;
|
||||||
fn type_for_def() for hir::db::TypeForDefQuery;
|
fn type_for_def() for hir::db::TypeForDefQuery;
|
||||||
|
@ -122,9 +122,6 @@ fn gc_syntax_trees(&mut self) {
|
|||||||
self.db
|
self.db
|
||||||
.query(ra_db::SourceFileQuery)
|
.query(ra_db::SourceFileQuery)
|
||||||
.sweep(salsa::SweepStrategy::default().discard_values());
|
.sweep(salsa::SweepStrategy::default().discard_values());
|
||||||
self.db
|
|
||||||
.query(hir::db::FnSyntaxQuery)
|
|
||||||
.sweep(salsa::SweepStrategy::default().discard_values());
|
|
||||||
self.db
|
self.db
|
||||||
.query(hir::db::SourceFileItemsQuery)
|
.query(hir::db::SourceFileItemsQuery)
|
||||||
.sweep(salsa::SweepStrategy::default().discard_values());
|
.sweep(salsa::SweepStrategy::default().discard_values());
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
SmolStr,
|
SmolStr,
|
||||||
SyntaxNode,
|
SyntaxNode,
|
||||||
ast::FnDefNode,
|
|
||||||
};
|
};
|
||||||
use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, FileId, Cancelable};
|
use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, FileId, Cancelable};
|
||||||
|
|
||||||
@ -12,7 +11,6 @@
|
|||||||
SourceFileItems, SourceItemId,
|
SourceFileItems, SourceItemId,
|
||||||
query_definitions,
|
query_definitions,
|
||||||
FnScopes,
|
FnScopes,
|
||||||
function::FnId,
|
|
||||||
module::{ModuleId, ModuleTree, ModuleSource,
|
module::{ModuleId, ModuleTree, ModuleSource,
|
||||||
nameres::{ItemMap, InputModuleItems}},
|
nameres::{ItemMap, InputModuleItems}},
|
||||||
ty::{InferenceResult, Ty},
|
ty::{InferenceResult, Ty},
|
||||||
@ -24,14 +22,10 @@
|
|||||||
pub trait HirDatabase: SyntaxDatabase
|
pub trait HirDatabase: SyntaxDatabase
|
||||||
+ AsRef<LocationIntener<DefLoc, DefId>>
|
+ AsRef<LocationIntener<DefLoc, DefId>>
|
||||||
{
|
{
|
||||||
fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
|
fn fn_scopes(def_id: DefId) -> Arc<FnScopes> {
|
||||||
type FnScopesQuery;
|
type FnScopesQuery;
|
||||||
use fn query_definitions::fn_scopes;
|
use fn query_definitions::fn_scopes;
|
||||||
}
|
}
|
||||||
fn fn_syntax(fn_id: FnId) -> FnDefNode {
|
|
||||||
type FnSyntaxQuery;
|
|
||||||
use fn query_definitions::fn_syntax;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn struct_data(def_id: DefId) -> Cancelable<Arc<StructData>> {
|
fn struct_data(def_id: DefId) -> Cancelable<Arc<StructData>> {
|
||||||
type StructDataQuery;
|
type StructDataQuery;
|
||||||
@ -43,7 +37,7 @@ fn enum_data(def_id: DefId) -> Cancelable<Arc<EnumData>> {
|
|||||||
use fn query_definitions::enum_data;
|
use fn query_definitions::enum_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn infer(fn_id: FnId) -> Cancelable<Arc<InferenceResult>> {
|
fn infer(def_id: DefId) -> Cancelable<Arc<InferenceResult>> {
|
||||||
type InferQuery;
|
type InferQuery;
|
||||||
use fn query_definitions::infer;
|
use fn query_definitions::infer;
|
||||||
}
|
}
|
||||||
|
@ -11,43 +11,42 @@
|
|||||||
ast::{self, AstNode, DocCommentsOwner, NameOwner},
|
ast::{self, AstNode, DocCommentsOwner, NameOwner},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{ DefId, HirDatabase, ty::InferenceResult, Module };
|
use crate::{DefId, DefKind, HirDatabase, ty::InferenceResult, Module};
|
||||||
|
|
||||||
pub use self::scope::FnScopes;
|
pub use self::scope::FnScopes;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
||||||
pub struct FnId(pub(crate) DefId);
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Function {
|
pub struct Function {
|
||||||
pub(crate) fn_id: FnId,
|
def_id: DefId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Function {
|
impl Function {
|
||||||
pub(crate) fn new(def_id: DefId) -> Function {
|
pub(crate) fn new(def_id: DefId) -> Function {
|
||||||
let fn_id = FnId(def_id);
|
Function { def_id }
|
||||||
Function { fn_id }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn syntax(&self, db: &impl HirDatabase) -> ast::FnDefNode {
|
pub fn syntax(&self, db: &impl HirDatabase) -> ast::FnDefNode {
|
||||||
db.fn_syntax(self.fn_id)
|
let def_loc = self.def_id.loc(db);
|
||||||
|
assert!(def_loc.kind == DefKind::Function);
|
||||||
|
let syntax = db.file_item(def_loc.source_item_id);
|
||||||
|
ast::FnDef::cast(syntax.borrowed()).unwrap().owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scopes(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
|
pub fn scopes(&self, db: &impl HirDatabase) -> Arc<FnScopes> {
|
||||||
db.fn_scopes(self.fn_id)
|
db.fn_scopes(self.def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signature_info(&self, db: &impl HirDatabase) -> Option<FnSignatureInfo> {
|
pub fn signature_info(&self, db: &impl HirDatabase) -> Option<FnSignatureInfo> {
|
||||||
let syntax = db.fn_syntax(self.fn_id);
|
let syntax = self.syntax(db);
|
||||||
FnSignatureInfo::new(syntax.borrowed())
|
FnSignatureInfo::new(syntax.borrowed())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn infer(&self, db: &impl HirDatabase) -> Cancelable<Arc<InferenceResult>> {
|
pub fn infer(&self, db: &impl HirDatabase) -> Cancelable<Arc<InferenceResult>> {
|
||||||
db.infer(self.fn_id)
|
db.infer(self.def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module(&self, db: &impl HirDatabase) -> Cancelable<Module> {
|
pub fn module(&self, db: &impl HirDatabase) -> Cancelable<Module> {
|
||||||
self.fn_id.0.module(db)
|
self.def_id.module(db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,6 @@ impl db::HirDatabase {
|
|||||||
fn file_item() for db::FileItemQuery;
|
fn file_item() for db::FileItemQuery;
|
||||||
fn input_module_items() for db::InputModuleItemsQuery;
|
fn input_module_items() for db::InputModuleItemsQuery;
|
||||||
fn item_map() for db::ItemMapQuery;
|
fn item_map() for db::ItemMapQuery;
|
||||||
fn fn_syntax() for db::FnSyntaxQuery;
|
|
||||||
fn submodules() for db::SubmodulesQuery;
|
fn submodules() for db::SubmodulesQuery;
|
||||||
fn infer() for db::InferQuery;
|
fn infer() for db::InferQuery;
|
||||||
fn type_for_def() for db::TypeForDefQuery;
|
fn type_for_def() for db::TypeForDefQuery;
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
AstNode, SyntaxNode, SmolStr,
|
AstNode, SyntaxNode, SmolStr,
|
||||||
ast::{self, FnDef, FnDefNode, NameOwner, ModuleItemOwner}
|
ast::{self, NameOwner, ModuleItemOwner}
|
||||||
};
|
};
|
||||||
use ra_db::{SourceRootId, FileId, Cancelable,};
|
use ra_db::{SourceRootId, FileId, Cancelable,};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
SourceFileItems, SourceItemId, DefKind, Function, DefId, Name, AsName,
|
SourceFileItems, SourceItemId, DefKind, Function, DefId, Name, AsName,
|
||||||
db::HirDatabase,
|
db::HirDatabase,
|
||||||
function::{FnScopes, FnId},
|
function::FnScopes,
|
||||||
module::{
|
module::{
|
||||||
ModuleSource, ModuleSourceNode, ModuleId,
|
ModuleSource, ModuleSourceNode, ModuleId,
|
||||||
imp::Submodule,
|
imp::Submodule,
|
||||||
@ -23,22 +23,15 @@
|
|||||||
adt::{StructData, EnumData},
|
adt::{StructData, EnumData},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Resolve `FnId` to the corresponding `SyntaxNode`
|
pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Arc<FnScopes> {
|
||||||
pub(super) fn fn_syntax(db: &impl HirDatabase, fn_id: FnId) -> FnDefNode {
|
let function = Function::new(def_id);
|
||||||
let def_loc = fn_id.0.loc(db);
|
let syntax = function.syntax(db);
|
||||||
assert!(def_loc.kind == DefKind::Function);
|
|
||||||
let syntax = db.file_item(def_loc.source_item_id);
|
|
||||||
FnDef::cast(syntax.borrowed()).unwrap().owned()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc<FnScopes> {
|
|
||||||
let syntax = db.fn_syntax(fn_id);
|
|
||||||
let res = FnScopes::new(syntax.borrowed());
|
let res = FnScopes::new(syntax.borrowed());
|
||||||
Arc::new(res)
|
Arc::new(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn infer(db: &impl HirDatabase, fn_id: FnId) -> Cancelable<Arc<InferenceResult>> {
|
pub(super) fn infer(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<InferenceResult>> {
|
||||||
let function = Function { fn_id };
|
let function = Function::new(def_id);
|
||||||
ty::infer(db, function).map(Arc::new)
|
ty::infer(db, function).map(Arc::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user