mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
Revert "Turn BlockId
into a #[salsa::tracked]
"
This reverts commit 8643a858dbaf12b37e90b603cdee64434576c229.
This commit is contained in:
parent
6807f60ccd
commit
6301c35cf3
@ -11,12 +11,12 @@ use syntax::{AstPtr, ast};
|
|||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
AssocItemId, AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, EnumVariantId,
|
AssocItemId, AttrDefId, BlockId, BlockLoc, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc,
|
||||||
EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId, ExternCrateLoc, FunctionId,
|
EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId, ExternCrateLoc,
|
||||||
FunctionLoc, GenericDefId, ImplId, ImplLoc, LocalFieldId, Macro2Id, Macro2Loc, MacroExpander,
|
FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, LocalFieldId, Macro2Id, Macro2Loc,
|
||||||
MacroId, MacroRulesId, MacroRulesLoc, MacroRulesLocFlags, ProcMacroId, ProcMacroLoc, StaticId,
|
MacroExpander, MacroId, MacroRulesId, MacroRulesLoc, MacroRulesLocFlags, ProcMacroId,
|
||||||
StaticLoc, StructId, StructLoc, TraitAliasId, TraitAliasLoc, TraitId, TraitLoc, TypeAliasId,
|
ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc, TraitAliasId, TraitAliasLoc, TraitId,
|
||||||
TypeAliasLoc, UnionId, UnionLoc, UseId, UseLoc, VariantId,
|
TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc, UseId, UseLoc, VariantId,
|
||||||
attr::{Attrs, AttrsWithOwner},
|
attr::{Attrs, AttrsWithOwner},
|
||||||
expr_store::{
|
expr_store::{
|
||||||
Body, BodySourceMap, ExpressionStore, ExpressionStoreSourceMap, scope::ExprScopes,
|
Body, BodySourceMap, ExpressionStore, ExpressionStoreSourceMap, scope::ExprScopes,
|
||||||
@ -90,7 +90,10 @@ pub trait InternDatabase: RootQueryDb {
|
|||||||
|
|
||||||
#[salsa::interned]
|
#[salsa::interned]
|
||||||
fn intern_macro_rules(&self, loc: MacroRulesLoc) -> MacroRulesId;
|
fn intern_macro_rules(&self, loc: MacroRulesLoc) -> MacroRulesId;
|
||||||
// // endregion: items
|
// endregion: items
|
||||||
|
|
||||||
|
#[salsa::interned]
|
||||||
|
fn intern_block(&self, loc: BlockLoc) -> BlockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[query_group::query_group]
|
#[query_group::query_group]
|
||||||
|
@ -11,7 +11,7 @@ use base_db::FxIndexSet;
|
|||||||
use cfg::CfgOptions;
|
use cfg::CfgOptions;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
HirFileId, InFile, Intern, MacroDefId,
|
HirFileId, InFile, MacroDefId,
|
||||||
mod_path::tool_path,
|
mod_path::tool_path,
|
||||||
name::{AsName, Name},
|
name::{AsName, Name},
|
||||||
span_map::SpanMapRef,
|
span_map::SpanMapRef,
|
||||||
@ -2148,7 +2148,7 @@ impl ExprCollector<'_> {
|
|||||||
) -> ExprId {
|
) -> ExprId {
|
||||||
let block_id = self.expander.ast_id_map().ast_id_for_block(&block).map(|file_local_id| {
|
let block_id = self.expander.ast_id_map().ast_id_for_block(&block).map(|file_local_id| {
|
||||||
let ast_id = self.expander.in_file(file_local_id);
|
let ast_id = self.expander.in_file(file_local_id);
|
||||||
BlockLoc { ast_id, module: self.module }.intern(self.db)
|
self.db.intern_block(BlockLoc { ast_id, module: self.module })
|
||||||
});
|
});
|
||||||
|
|
||||||
let (module, def_map) =
|
let (module, def_map) =
|
||||||
|
@ -189,8 +189,8 @@ fn f() {
|
|||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
BlockIdLt { [salsa id]: Id(3c01) } in BlockRelativeModuleId { block: Some(BlockIdLt { [salsa id]: Id(3c00) }), local_id: Idx::<ModuleData>(1) }
|
BlockId(3c01) in BlockRelativeModuleId { block: Some(BlockId(3c00)), local_id: Idx::<ModuleData>(1) }
|
||||||
BlockIdLt { [salsa id]: Id(3c00) } in BlockRelativeModuleId { block: None, local_id: Idx::<ModuleData>(0) }
|
BlockId(3c00) in BlockRelativeModuleId { block: None, local_id: Idx::<ModuleData>(0) }
|
||||||
crate scope
|
crate scope
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
@ -384,26 +384,7 @@ pub struct BlockLoc {
|
|||||||
/// The containing module.
|
/// The containing module.
|
||||||
pub module: ModuleId,
|
pub module: ModuleId,
|
||||||
}
|
}
|
||||||
#[salsa_macros::tracked(debug)]
|
impl_intern!(BlockId, BlockLoc, intern_block, lookup_intern_block);
|
||||||
#[derive(PartialOrd, Ord)]
|
|
||||||
pub struct BlockIdLt<'db> {
|
|
||||||
pub loc: BlockLoc,
|
|
||||||
}
|
|
||||||
pub type BlockId = BlockIdLt<'static>;
|
|
||||||
impl hir_expand::Intern for BlockLoc {
|
|
||||||
type Database = dyn DefDatabase;
|
|
||||||
type ID = BlockId;
|
|
||||||
fn intern(self, db: &Self::Database) -> Self::ID {
|
|
||||||
unsafe { std::mem::transmute::<BlockIdLt<'_>, BlockId>(BlockIdLt::new(db, self)) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl hir_expand::Lookup for BlockId {
|
|
||||||
type Database = dyn DefDatabase;
|
|
||||||
type Data = BlockLoc;
|
|
||||||
fn lookup(&self, db: &Self::Database) -> Self::Data {
|
|
||||||
self.loc(db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A `ModuleId` that is always a crate's root module.
|
/// A `ModuleId` that is always a crate's root module.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
@ -283,16 +283,12 @@ pub(crate) fn complete_postfix(
|
|||||||
let (open_brace, close_brace) =
|
let (open_brace, close_brace) =
|
||||||
if block_should_be_wrapped { ("{ ", " }") } else { ("", "") };
|
if block_should_be_wrapped { ("{ ", " }") } else { ("", "") };
|
||||||
let (open_paren, close_paren) = if is_in_cond { ("(", ")") } else { ("", "") };
|
let (open_paren, close_paren) = if is_in_cond { ("(", ")") } else { ("", "") };
|
||||||
let unsafe_completion_string = format!(
|
let unsafe_completion_string =
|
||||||
"{}unsafe {}{receiver_text}{}{}",
|
format!("{open_paren}unsafe {open_brace}{receiver_text}{close_brace}{close_paren}");
|
||||||
open_paren, open_brace, close_brace, close_paren
|
|
||||||
);
|
|
||||||
postfix_snippet("unsafe", "unsafe {}", &unsafe_completion_string).add_to(acc, ctx.db);
|
postfix_snippet("unsafe", "unsafe {}", &unsafe_completion_string).add_to(acc, ctx.db);
|
||||||
|
|
||||||
let const_completion_string = format!(
|
let const_completion_string =
|
||||||
"{}const {}{receiver_text}{}{}",
|
format!("{open_paren}const {open_brace}{receiver_text}{close_brace}{close_paren}");
|
||||||
open_paren, open_brace, close_brace, close_paren
|
|
||||||
);
|
|
||||||
postfix_snippet("const", "const {}", &const_completion_string).add_to(acc, ctx.db);
|
postfix_snippet("const", "const {}", &const_completion_string).add_to(acc, ctx.db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user