mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Make HirFileId, EditionedFileId and macro files Salsa struct
And make more queries non-interned. Also flip the default for queries, now the default is to not intern and to intern a query you need to say `invoke_interned`.
This commit is contained in:
parent
02ade79631
commit
c58ddafe90
195 changed files with 1473 additions and 1525 deletions
|
|
@ -1,4 +1,3 @@
|
|||
use salsa::AsDynDatabase;
|
||||
use stdx::trim_indent;
|
||||
use test_fixture::WithFixture;
|
||||
use test_utils::{CURSOR_MARKER, assert_eq_text};
|
||||
|
|
@ -1252,14 +1251,10 @@ fn check_with_config(
|
|||
let (db, file_id, pos) = if ra_fixture_before.contains(CURSOR_MARKER) {
|
||||
let (db, file_id, range_or_offset) = RootDatabase::with_range_or_offset(ra_fixture_before);
|
||||
|
||||
let file_id = crate::base_db::EditionedFileId::new(db.as_dyn_database(), file_id);
|
||||
|
||||
(db, file_id, Some(range_or_offset))
|
||||
} else {
|
||||
let (db, file_id) = RootDatabase::with_single_file(ra_fixture_before);
|
||||
|
||||
let file_id = crate::base_db::EditionedFileId::new(db.as_dyn_database(), file_id);
|
||||
|
||||
(db, file_id, None)
|
||||
};
|
||||
let sema = &Semantics::new(&db);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ pub mod syntax_helpers {
|
|||
pub use parser::LexedStr;
|
||||
}
|
||||
|
||||
pub use hir::ChangeWithProcMacros;
|
||||
pub use hir::{ChangeWithProcMacros, EditionedFileId};
|
||||
use salsa::Durability;
|
||||
|
||||
use std::{fmt, mem::ManuallyDrop};
|
||||
|
|
@ -67,7 +67,7 @@ pub use ::line_index;
|
|||
|
||||
/// `base_db` is normally also needed in places where `ide_db` is used, so this re-export is for convenience.
|
||||
pub use base_db;
|
||||
pub use span::{EditionedFileId, FileId};
|
||||
pub use span::{self, FileId};
|
||||
|
||||
pub type FxIndexSet<T> = indexmap::IndexSet<T, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
|
||||
pub type FxIndexMap<K, V> =
|
||||
|
|
@ -246,6 +246,7 @@ impl RootDatabase {
|
|||
|
||||
#[query_group::query_group]
|
||||
pub trait LineIndexDatabase: base_db::RootQueryDb {
|
||||
#[salsa::invoke_interned(line_index)]
|
||||
fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ use crate::{
|
|||
};
|
||||
use base_db::AnchoredPathBuf;
|
||||
use either::Either;
|
||||
use hir::{FieldSource, FileRange, HirFileIdExt, InFile, ModuleSource, Semantics};
|
||||
use span::{Edition, EditionedFileId, FileId, SyntaxContext};
|
||||
use hir::{EditionedFileId, FieldSource, FileRange, InFile, ModuleSource, Semantics};
|
||||
use span::{Edition, FileId, SyntaxContext};
|
||||
use stdx::{TupleExt, never};
|
||||
use syntax::{
|
||||
AstNode, SyntaxKind, T, TextRange,
|
||||
|
|
@ -249,7 +249,7 @@ fn rename_mod(
|
|||
|
||||
let InFile { file_id, value: def_source } = module.definition_source(sema.db);
|
||||
if let ModuleSource::SourceFile(..) = def_source {
|
||||
let anchor = file_id.original_file(sema.db).file_id();
|
||||
let anchor = file_id.original_file(sema.db).file_id(sema.db);
|
||||
|
||||
let is_mod_rs = module.is_mod_rs(sema.db);
|
||||
let has_detached_child = module.children(sema.db).any(|child| !child.is_inline(sema.db));
|
||||
|
|
@ -296,13 +296,13 @@ fn rename_mod(
|
|||
.original_file_range_opt(sema.db)
|
||||
.map(TupleExt::head)
|
||||
{
|
||||
let new_name = if is_raw_identifier(new_name, file_id.edition()) {
|
||||
let new_name = if is_raw_identifier(new_name, file_id.edition(sema.db)) {
|
||||
format!("r#{new_name}")
|
||||
} else {
|
||||
new_name.to_owned()
|
||||
};
|
||||
source_change.insert_source_edit(
|
||||
file_id.file_id(),
|
||||
file_id.file_id(sema.db),
|
||||
TextEdit::replace(file_range.range, new_name),
|
||||
)
|
||||
};
|
||||
|
|
@ -315,8 +315,8 @@ fn rename_mod(
|
|||
let usages = def.usages(sema).all();
|
||||
let ref_edits = usages.iter().map(|(file_id, references)| {
|
||||
(
|
||||
EditionedFileId::file_id(file_id),
|
||||
source_edit_from_references(references, def, new_name, file_id.edition()),
|
||||
file_id.file_id(sema.db),
|
||||
source_edit_from_references(references, def, new_name, file_id.edition(sema.db)),
|
||||
)
|
||||
});
|
||||
source_change.extend(ref_edits);
|
||||
|
|
@ -362,8 +362,8 @@ fn rename_reference(
|
|||
let mut source_change = SourceChange::default();
|
||||
source_change.extend(usages.iter().map(|(file_id, references)| {
|
||||
(
|
||||
EditionedFileId::file_id(file_id),
|
||||
source_edit_from_references(references, def, new_name, file_id.edition()),
|
||||
file_id.file_id(sema.db),
|
||||
source_edit_from_references(references, def, new_name, file_id.edition(sema.db)),
|
||||
)
|
||||
}));
|
||||
|
||||
|
|
@ -541,7 +541,7 @@ fn source_edit_from_def(
|
|||
source_change: &mut SourceChange,
|
||||
) -> Result<(FileId, TextEdit)> {
|
||||
let new_name_edition_aware = |new_name: &str, file_id: EditionedFileId| {
|
||||
if is_raw_identifier(new_name, file_id.edition()) {
|
||||
if is_raw_identifier(new_name, file_id.edition(sema.db)) {
|
||||
format!("r#{new_name}")
|
||||
} else {
|
||||
new_name.to_owned()
|
||||
|
|
@ -638,7 +638,7 @@ fn source_edit_from_def(
|
|||
edit.set_annotation(conflict_annotation);
|
||||
|
||||
let Some(file_id) = file_id else { bail!("No file available to rename") };
|
||||
return Ok((EditionedFileId::file_id(file_id), edit));
|
||||
return Ok((file_id.file_id(sema.db), edit));
|
||||
}
|
||||
let FileRange { file_id, range } = def
|
||||
.range_for_rename(sema)
|
||||
|
|
@ -654,7 +654,7 @@ fn source_edit_from_def(
|
|||
_ => (range, new_name.to_owned()),
|
||||
};
|
||||
edit.replace(range, new_name_edition_aware(&new_name, file_id));
|
||||
Ok((file_id.file_id(), edit.finish()))
|
||||
Ok((file_id.file_id(sema.db), edit.finish()))
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
|
|
|
|||
|
|
@ -10,15 +10,14 @@ use std::{cell::LazyCell, cmp::Reverse};
|
|||
use base_db::{RootQueryDb, SourceDatabase};
|
||||
use either::Either;
|
||||
use hir::{
|
||||
Adt, AsAssocItem, DefWithBody, FileRange, FileRangeWrapper, HasAttrs, HasContainer, HasSource,
|
||||
HirFileIdExt, InFile, InFileWrapper, InRealFile, InlineAsmOperand, ItemContainer, ModuleSource,
|
||||
PathResolution, Semantics, Visibility, sym,
|
||||
Adt, AsAssocItem, DefWithBody, EditionedFileId, FileRange, FileRangeWrapper, HasAttrs,
|
||||
HasContainer, HasSource, InFile, InFileWrapper, InRealFile, InlineAsmOperand, ItemContainer,
|
||||
ModuleSource, PathResolution, Semantics, Visibility, sym,
|
||||
};
|
||||
use memchr::memmem::Finder;
|
||||
use parser::SyntaxKind;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use salsa::Database;
|
||||
use span::EditionedFileId;
|
||||
use syntax::{
|
||||
AstNode, AstToken, SmolStr, SyntaxElement, SyntaxNode, TextRange, TextSize, ToSmolStr,
|
||||
ast::{self, HasName, Rename},
|
||||
|
|
@ -168,7 +167,9 @@ impl SearchScope {
|
|||
let source_root = db.file_source_root(crate_data.root_file_id).source_root_id(db);
|
||||
let source_root = db.source_root(source_root).source_root(db);
|
||||
entries.extend(
|
||||
source_root.iter().map(|id| (EditionedFileId::new(id, crate_data.edition), None)),
|
||||
source_root
|
||||
.iter()
|
||||
.map(|id| (EditionedFileId::new(db, id, crate_data.edition), None)),
|
||||
);
|
||||
}
|
||||
SearchScope { entries }
|
||||
|
|
@ -183,7 +184,9 @@ impl SearchScope {
|
|||
let source_root = db.file_source_root(root_file).source_root_id(db);
|
||||
let source_root = db.source_root(source_root).source_root(db);
|
||||
entries.extend(
|
||||
source_root.iter().map(|id| (EditionedFileId::new(id, rev_dep.edition(db)), None)),
|
||||
source_root
|
||||
.iter()
|
||||
.map(|id| (EditionedFileId::new(db, id, rev_dep.edition(db)), None)),
|
||||
);
|
||||
}
|
||||
SearchScope { entries }
|
||||
|
|
@ -198,7 +201,7 @@ impl SearchScope {
|
|||
SearchScope {
|
||||
entries: source_root
|
||||
.iter()
|
||||
.map(|id| (EditionedFileId::new(id, of.edition(db)), None))
|
||||
.map(|id| (EditionedFileId::new(db, id, of.edition(db)), None))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
|
@ -482,7 +485,7 @@ impl<'a> FindUsages<'a> {
|
|||
scope: &'b SearchScope,
|
||||
) -> impl Iterator<Item = (Arc<str>, EditionedFileId, TextRange)> + 'b {
|
||||
scope.entries.iter().map(|(&file_id, &search_range)| {
|
||||
let text = db.file_text(file_id.file_id()).text(db);
|
||||
let text = db.file_text(file_id.file_id(db)).text(db);
|
||||
let search_range =
|
||||
search_range.unwrap_or_else(|| TextRange::up_to(TextSize::of(&*text)));
|
||||
|
||||
|
|
@ -648,8 +651,6 @@ impl<'a> FindUsages<'a> {
|
|||
for (file_text, file_id, search_range) in
|
||||
FindUsages::scope_files(db, ¤t_to_process_search_scope)
|
||||
{
|
||||
let file_id = crate::base_db::EditionedFileId::new(db, file_id);
|
||||
|
||||
let tree = LazyCell::new(move || sema.parse(file_id).syntax().clone());
|
||||
|
||||
for offset in FindUsages::match_indices(&file_text, &finder, search_range) {
|
||||
|
|
@ -809,9 +810,7 @@ impl<'a> FindUsages<'a> {
|
|||
sink: &mut dyn FnMut(EditionedFileId, FileReference) -> bool,
|
||||
) {
|
||||
for (file_text, file_id, search_range) in files {
|
||||
let file_id_wrapper = crate::base_db::EditionedFileId::new(this.sema.db, file_id);
|
||||
|
||||
let tree = LazyCell::new(move || this.sema.parse(file_id_wrapper).syntax().clone());
|
||||
let tree = LazyCell::new(move || this.sema.parse(file_id).syntax().clone());
|
||||
|
||||
for offset in FindUsages::match_indices(&file_text, finder, search_range) {
|
||||
let usages = FindUsages::find_nodes(this.sema, name, &tree, offset)
|
||||
|
|
@ -856,7 +855,10 @@ impl<'a> FindUsages<'a> {
|
|||
name,
|
||||
is_possibly_self.into_iter().map(|position| {
|
||||
(
|
||||
self.sema.db.file_text(position.file_id.file_id()).text(self.sema.db),
|
||||
self.sema
|
||||
.db
|
||||
.file_text(position.file_id.file_id(self.sema.db))
|
||||
.text(self.sema.db),
|
||||
position.file_id,
|
||||
position.range,
|
||||
)
|
||||
|
|
@ -950,9 +952,7 @@ impl<'a> FindUsages<'a> {
|
|||
let include_self_kw_refs =
|
||||
self.include_self_kw_refs.as_ref().map(|ty| (ty, Finder::new("Self")));
|
||||
for (text, file_id, search_range) in Self::scope_files(sema.db, &search_scope) {
|
||||
let file_id_wrapper = crate::base_db::EditionedFileId::new(sema.db, file_id);
|
||||
|
||||
let tree = LazyCell::new(move || sema.parse(file_id_wrapper).syntax().clone());
|
||||
let tree = LazyCell::new(move || sema.parse(file_id).syntax().clone());
|
||||
|
||||
// Search for occurrences of the items name
|
||||
for offset in Self::match_indices(&text, finder, search_range) {
|
||||
|
|
@ -1007,8 +1007,7 @@ impl<'a> FindUsages<'a> {
|
|||
for (text, file_id, search_range) in Self::scope_files(sema.db, &scope) {
|
||||
self.sema.db.unwind_if_revision_cancelled();
|
||||
|
||||
let file_id_wrapper = crate::base_db::EditionedFileId::new(sema.db, file_id);
|
||||
let tree = LazyCell::new(move || sema.parse(file_id_wrapper).syntax().clone());
|
||||
let tree = LazyCell::new(move || sema.parse(file_id).syntax().clone());
|
||||
|
||||
for offset in Self::match_indices(&text, finder, search_range) {
|
||||
for name_ref in Self::find_nodes(sema, "super", &tree, offset)
|
||||
|
|
@ -1056,13 +1055,11 @@ impl<'a> FindUsages<'a> {
|
|||
return;
|
||||
};
|
||||
|
||||
let file_text = sema.db.file_text(file_id.file_id());
|
||||
let file_text = sema.db.file_text(file_id.file_id(self.sema.db));
|
||||
let text = file_text.text(sema.db);
|
||||
let search_range =
|
||||
search_range.unwrap_or_else(|| TextRange::up_to(TextSize::of(&*text)));
|
||||
|
||||
let file_id = crate::base_db::EditionedFileId::new(sema.db, file_id);
|
||||
|
||||
let tree = LazyCell::new(|| sema.parse(file_id).syntax().clone());
|
||||
let finder = &Finder::new("self");
|
||||
|
||||
|
|
|
|||
|
|
@ -100,9 +100,13 @@ impl Query {
|
|||
pub trait SymbolsDatabase: HirDatabase + SourceDatabase {
|
||||
/// The symbol index for a given module. These modules should only be in source roots that
|
||||
/// are inside local_roots.
|
||||
// FIXME: Is it worth breaking the encapsulation boundary of `hir`, and make this take a `ModuleId`,
|
||||
// in order for it to be a non-interned query?
|
||||
#[salsa::invoke_interned(module_symbols)]
|
||||
fn module_symbols(&self, module: Module) -> Arc<SymbolIndex>;
|
||||
|
||||
/// The symbol index for a given source root within library_roots.
|
||||
#[salsa::invoke_interned(library_symbols)]
|
||||
fn library_symbols(&self, source_root_id: SourceRootId) -> Arc<SymbolIndex>;
|
||||
|
||||
#[salsa::transparent]
|
||||
|
|
|
|||
|
|
@ -455,8 +455,7 @@ mod tests {
|
|||
let frange = FileRange { file_id, range: range_or_offset.into() };
|
||||
let sema = Semantics::new(&db);
|
||||
|
||||
let file_id = crate::base_db::EditionedFileId::new(sema.db, frange.file_id);
|
||||
let source_file = sema.parse(file_id);
|
||||
let source_file = sema.parse(frange.file_id);
|
||||
|
||||
let element = source_file.syntax().covering_element(frange.range);
|
||||
let expr =
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Module {
|
||||
id: ModuleId {
|
||||
krate: Crate(
|
||||
Id(2c00),
|
||||
Id(3000),
|
||||
),
|
||||
block: None,
|
||||
local_id: Idx::<ModuleData>(0),
|
||||
|
|
@ -16,17 +16,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
4001,
|
||||
3401,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -50,17 +49,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
4000,
|
||||
3400,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -84,17 +82,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
4000,
|
||||
3400,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -118,17 +115,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
4000,
|
||||
3400,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -152,17 +148,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
4000,
|
||||
3400,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -186,17 +181,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
4001,
|
||||
3401,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -220,17 +214,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
4000,
|
||||
3400,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Module {
|
||||
id: ModuleId {
|
||||
krate: Crate(
|
||||
Id(2c00),
|
||||
Id(3000),
|
||||
),
|
||||
block: None,
|
||||
local_id: Idx::<ModuleData>(0),
|
||||
|
|
@ -15,16 +15,15 @@
|
|||
def: TypeAlias(
|
||||
TypeAlias {
|
||||
id: TypeAliasId(
|
||||
7c00,
|
||||
6800,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: TYPE_ALIAS,
|
||||
|
|
@ -47,16 +46,15 @@
|
|||
def: Const(
|
||||
Const {
|
||||
id: ConstId(
|
||||
7400,
|
||||
6000,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: CONST,
|
||||
|
|
@ -79,16 +77,15 @@
|
|||
def: Const(
|
||||
Const {
|
||||
id: ConstId(
|
||||
7402,
|
||||
6002,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: CONST,
|
||||
|
|
@ -112,17 +109,16 @@
|
|||
Enum(
|
||||
Enum {
|
||||
id: EnumId(
|
||||
6000,
|
||||
4c00,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: ENUM,
|
||||
|
|
@ -146,17 +142,16 @@
|
|||
Macro {
|
||||
id: Macro2Id(
|
||||
Macro2Id(
|
||||
5c00,
|
||||
4800,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: USE_TREE,
|
||||
|
|
@ -180,17 +175,16 @@
|
|||
Macro {
|
||||
id: Macro2Id(
|
||||
Macro2Id(
|
||||
5c00,
|
||||
4800,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: MACRO_DEF,
|
||||
|
|
@ -213,16 +207,15 @@
|
|||
def: Static(
|
||||
Static {
|
||||
id: StaticId(
|
||||
7800,
|
||||
6400,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STATIC,
|
||||
|
|
@ -246,17 +239,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5801,
|
||||
4401,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -280,14 +272,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5800,
|
||||
4400,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: MacroFile(
|
||||
Id(4400),
|
||||
MacroCallId(
|
||||
Id(3800),
|
||||
),
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -311,17 +305,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5805,
|
||||
4405,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -347,17 +340,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5806,
|
||||
4406,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -383,17 +375,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5807,
|
||||
4407,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -417,17 +408,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5802,
|
||||
4402,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -450,16 +440,15 @@
|
|||
def: Trait(
|
||||
Trait {
|
||||
id: TraitId(
|
||||
6c00,
|
||||
5800,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: TRAIT,
|
||||
|
|
@ -483,17 +472,16 @@
|
|||
Macro {
|
||||
id: Macro2Id(
|
||||
Macro2Id(
|
||||
5c00,
|
||||
4800,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: USE_TREE,
|
||||
|
|
@ -517,17 +505,16 @@
|
|||
Union(
|
||||
Union {
|
||||
id: UnionId(
|
||||
6400,
|
||||
5000,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: UNION,
|
||||
|
|
@ -551,7 +538,7 @@
|
|||
Module {
|
||||
id: ModuleId {
|
||||
krate: Crate(
|
||||
Id(2c00),
|
||||
Id(3000),
|
||||
),
|
||||
block: None,
|
||||
local_id: Idx::<ModuleData>(1),
|
||||
|
|
@ -559,11 +546,10 @@
|
|||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: MODULE,
|
||||
|
|
@ -587,7 +573,7 @@
|
|||
Module {
|
||||
id: ModuleId {
|
||||
krate: Crate(
|
||||
Id(2c00),
|
||||
Id(3000),
|
||||
),
|
||||
block: None,
|
||||
local_id: Idx::<ModuleData>(2),
|
||||
|
|
@ -595,11 +581,10 @@
|
|||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: MODULE,
|
||||
|
|
@ -623,17 +608,16 @@
|
|||
Macro {
|
||||
id: MacroRulesId(
|
||||
MacroRulesId(
|
||||
4001,
|
||||
3401,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: MACRO_RULES,
|
||||
|
|
@ -656,16 +640,15 @@
|
|||
def: Function(
|
||||
Function {
|
||||
id: FunctionId(
|
||||
7002,
|
||||
5c02,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: FN,
|
||||
|
|
@ -690,16 +673,15 @@
|
|||
def: Function(
|
||||
Function {
|
||||
id: FunctionId(
|
||||
7001,
|
||||
5c01,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: FN,
|
||||
|
|
@ -725,17 +707,16 @@
|
|||
Macro {
|
||||
id: MacroRulesId(
|
||||
MacroRulesId(
|
||||
4000,
|
||||
3400,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: MACRO_RULES,
|
||||
|
|
@ -758,16 +739,15 @@
|
|||
def: Function(
|
||||
Function {
|
||||
id: FunctionId(
|
||||
7000,
|
||||
5c00,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: FN,
|
||||
|
|
@ -791,17 +771,16 @@
|
|||
Macro {
|
||||
id: MacroRulesId(
|
||||
MacroRulesId(
|
||||
4001,
|
||||
3401,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: USE_TREE,
|
||||
|
|
@ -824,16 +803,15 @@
|
|||
def: Function(
|
||||
Function {
|
||||
id: FunctionId(
|
||||
7003,
|
||||
5c03,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: FN,
|
||||
|
|
@ -859,7 +837,7 @@
|
|||
Module {
|
||||
id: ModuleId {
|
||||
krate: Crate(
|
||||
Id(2c00),
|
||||
Id(3000),
|
||||
),
|
||||
block: None,
|
||||
local_id: Idx::<ModuleData>(1),
|
||||
|
|
@ -872,17 +850,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5803,
|
||||
4403,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
0,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -906,7 +883,7 @@
|
|||
Module {
|
||||
id: ModuleId {
|
||||
krate: Crate(
|
||||
Id(2c00),
|
||||
Id(3000),
|
||||
),
|
||||
block: None,
|
||||
local_id: Idx::<ModuleData>(2),
|
||||
|
|
@ -918,16 +895,15 @@
|
|||
def: Trait(
|
||||
Trait {
|
||||
id: TraitId(
|
||||
6c00,
|
||||
5800,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
1,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2001),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: USE_TREE,
|
||||
|
|
@ -951,17 +927,16 @@
|
|||
Macro {
|
||||
id: Macro2Id(
|
||||
Macro2Id(
|
||||
5c00,
|
||||
4800,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
1,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2001),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: USE_TREE,
|
||||
|
|
@ -985,17 +960,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5804,
|
||||
4404,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
1,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2001),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: STRUCT,
|
||||
|
|
@ -1019,17 +993,16 @@
|
|||
Macro {
|
||||
id: Macro2Id(
|
||||
Macro2Id(
|
||||
5c00,
|
||||
4800,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
1,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2001),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: USE_TREE,
|
||||
|
|
@ -1053,17 +1026,16 @@
|
|||
Struct(
|
||||
Struct {
|
||||
id: StructId(
|
||||
5804,
|
||||
4404,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: EditionedFileId(
|
||||
FileId(
|
||||
1,
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2001),
|
||||
),
|
||||
Edition2024,
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: USE_TREE,
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ mod tests {
|
|||
use expect_test::{Expect, expect};
|
||||
use hir::FilePosition;
|
||||
use hir::Semantics;
|
||||
use salsa::AsDynDatabase;
|
||||
use span::Edition;
|
||||
use syntax::ast::{self, AstNode};
|
||||
use test_fixture::ChangeFixture;
|
||||
|
|
@ -127,8 +126,8 @@ mod tests {
|
|||
pub(crate) fn position(
|
||||
#[rust_analyzer::rust_fixture] ra_fixture: &str,
|
||||
) -> (RootDatabase, FilePosition) {
|
||||
let change_fixture = ChangeFixture::parse(ra_fixture);
|
||||
let mut database = RootDatabase::default();
|
||||
let change_fixture = ChangeFixture::parse(&database, ra_fixture);
|
||||
database.apply_change(change_fixture.change);
|
||||
let (file_id, range_or_offset) =
|
||||
change_fixture.file_position.expect("expected a marker ($0)");
|
||||
|
|
@ -140,10 +139,7 @@ mod tests {
|
|||
let (db, position) = position(ra_fixture);
|
||||
let sema = Semantics::new(&db);
|
||||
|
||||
let editioned_file_id =
|
||||
crate::base_db::EditionedFileId::new(sema.db.as_dyn_database(), position.file_id);
|
||||
|
||||
let file = sema.parse(editioned_file_id);
|
||||
let file = sema.parse(position.file_id);
|
||||
let impl_block: ast::Impl =
|
||||
sema.find_node_at_offset_with_descend(file.syntax(), position.offset).unwrap();
|
||||
let trait_ = crate::traits::resolve_target_trait(&sema, &impl_block);
|
||||
|
|
@ -158,10 +154,7 @@ mod tests {
|
|||
let (db, position) = position(ra_fixture);
|
||||
let sema = Semantics::new(&db);
|
||||
|
||||
let editioned_file_id =
|
||||
crate::base_db::EditionedFileId::new(sema.db.as_dyn_database(), position.file_id);
|
||||
|
||||
let file = sema.parse(editioned_file_id);
|
||||
let file = sema.parse(position.file_id);
|
||||
let impl_block: ast::Impl =
|
||||
sema.find_node_at_offset_with_descend(file.syntax(), position.offset).unwrap();
|
||||
let items = crate::traits::get_missing_assoc_items(&sema, &impl_block);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue