mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Pull macro up
This commit is contained in:
parent
f11237561c
commit
53506a7552
3 changed files with 16 additions and 28 deletions
|
@ -15,6 +15,20 @@ pub use crate::{
|
||||||
pub use relative_path::{RelativePath, RelativePathBuf};
|
pub use relative_path::{RelativePath, RelativePathBuf};
|
||||||
pub use salsa;
|
pub use salsa;
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! impl_intern_key {
|
||||||
|
($name:ident) => {
|
||||||
|
impl $crate::salsa::InternKey for $name {
|
||||||
|
fn from_intern_id(v: $crate::salsa::InternId) -> Self {
|
||||||
|
$name(v)
|
||||||
|
}
|
||||||
|
fn as_intern_id(&self) -> $crate::salsa::InternId {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub trait CheckCanceled {
|
pub trait CheckCanceled {
|
||||||
/// Aborts current query if there are pending changes.
|
/// Aborts current query if there are pending changes.
|
||||||
///
|
///
|
||||||
|
|
|
@ -5,20 +5,7 @@
|
||||||
//! This module defines a bunch of ids we are using. The most important ones are
|
//! This module defines a bunch of ids we are using. The most important ones are
|
||||||
//! probably `HirFileId` and `DefId`.
|
//! probably `HirFileId` and `DefId`.
|
||||||
|
|
||||||
use ra_db::salsa;
|
use ra_db::{impl_intern_key, salsa};
|
||||||
|
|
||||||
macro_rules! impl_intern_key {
|
|
||||||
($name:ident) => {
|
|
||||||
impl salsa::InternKey for $name {
|
|
||||||
fn from_intern_id(v: salsa::InternId) -> Self {
|
|
||||||
$name(v)
|
|
||||||
}
|
|
||||||
fn as_intern_id(&self) -> salsa::InternId {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This exists just for Chalk, because Chalk just has a single `StructId` where
|
/// This exists just for Chalk, because Chalk just has a single `StructId` where
|
||||||
/// we have different kinds of ADTs, primitive types and special type
|
/// we have different kinds of ADTs, primitive types and special type
|
||||||
|
|
|
@ -35,7 +35,7 @@ use std::hash::{Hash, Hasher};
|
||||||
|
|
||||||
use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, MacroDefId, Source};
|
use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, MacroDefId, Source};
|
||||||
use ra_arena::{impl_arena_id, map::ArenaMap, RawId};
|
use ra_arena::{impl_arena_id, map::ArenaMap, RawId};
|
||||||
use ra_db::{salsa, CrateId};
|
use ra_db::{impl_intern_key, salsa, CrateId};
|
||||||
use ra_syntax::{ast, AstNode};
|
use ra_syntax::{ast, AstNode};
|
||||||
|
|
||||||
use crate::{builtin_type::BuiltinType, db::InternDatabase};
|
use crate::{builtin_type::BuiltinType, db::InternDatabase};
|
||||||
|
@ -56,19 +56,6 @@ pub struct ModuleId {
|
||||||
pub struct LocalModuleId(RawId);
|
pub struct LocalModuleId(RawId);
|
||||||
impl_arena_id!(LocalModuleId);
|
impl_arena_id!(LocalModuleId);
|
||||||
|
|
||||||
macro_rules! impl_intern_key {
|
|
||||||
($name:ident) => {
|
|
||||||
impl salsa::InternKey for $name {
|
|
||||||
fn from_intern_id(v: salsa::InternId) -> Self {
|
|
||||||
$name(v)
|
|
||||||
}
|
|
||||||
fn as_intern_id(&self) -> salsa::InternId {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ItemLoc<N: AstNode> {
|
pub struct ItemLoc<N: AstNode> {
|
||||||
pub(crate) module: ModuleId,
|
pub(crate) module: ModuleId,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue