Move AttrId back into hir_def

This commit is contained in:
Jonas Schievink 2021-05-10 16:35:06 +02:00
parent 07cea5e709
commit a87bec5148
5 changed files with 12 additions and 12 deletions

View file

@ -9,7 +9,7 @@ use std::{
use base_db::CrateId; use base_db::CrateId;
use cfg::{CfgExpr, CfgOptions}; use cfg::{CfgExpr, CfgOptions};
use either::Either; use either::Either;
use hir_expand::{hygiene::Hygiene, name::AsName, AstId, AttrId, InFile}; use hir_expand::{hygiene::Hygiene, name::AsName, AstId, InFile};
use itertools::Itertools; use itertools::Itertools;
use la_arena::ArenaMap; use la_arena::ArenaMap;
use mbe::ast_to_token_tree; use mbe::ast_to_token_tree;
@ -615,6 +615,9 @@ impl DocsRangeMap {
} }
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct AttrId(pub u32);
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct Attr { pub struct Attr {
pub(crate) id: AttrId, pub(crate) id: AttrId,

View file

@ -62,14 +62,14 @@ use hir_expand::{
ast_id_map::FileAstId, ast_id_map::FileAstId,
eager::{expand_eager_macro, ErrorEmitted, ErrorSink}, eager::{expand_eager_macro, ErrorEmitted, ErrorSink},
hygiene::Hygiene, hygiene::Hygiene,
AstId, AttrId, FragmentKind, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, AstId, FragmentKind, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
MacroDefKind,
}; };
use la_arena::Idx; use la_arena::Idx;
use nameres::DefMap; use nameres::DefMap;
use path::ModPath; use path::ModPath;
use syntax::ast; use syntax::ast;
use crate::attr::AttrId;
use crate::builtin_type::BuiltinType; use crate::builtin_type::BuiltinType;
use item_tree::{ use item_tree::{
Const, Enum, Function, Impl, ItemTreeId, ItemTreeNode, ModItem, Static, Struct, Trait, Const, Enum, Function, Impl, ItemTreeId, ItemTreeNode, ModItem, Static, Struct, Trait,
@ -753,7 +753,7 @@ fn derive_macro_as_call_id(
MacroCallKind::Derive { MacroCallKind::Derive {
ast_id: item_attr.ast_id, ast_id: item_attr.ast_id,
derive_name: last_segment.to_string(), derive_name: last_segment.to_string(),
derive_attr, derive_attr_index: derive_attr.0,
}, },
) )
.into(); .into();

View file

@ -13,14 +13,14 @@ use hir_expand::{
builtin_macro::find_builtin_macro, builtin_macro::find_builtin_macro,
name::{AsName, Name}, name::{AsName, Name},
proc_macro::ProcMacroExpander, proc_macro::ProcMacroExpander,
AttrId, FragmentKind, HirFileId, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, FragmentKind, HirFileId, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
}; };
use hir_expand::{InFile, MacroCallLoc}; use hir_expand::{InFile, MacroCallLoc};
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use syntax::ast; use syntax::ast;
use crate::{ use crate::{
attr::Attrs, attr::{AttrId, Attrs},
db::DefDatabase, db::DefDatabase,
derive_macro_as_call_id, derive_macro_as_call_id,
intern::Interned, intern::Interned,

View file

@ -269,7 +269,7 @@ mod tests {
use expect_test::{expect, Expect}; use expect_test::{expect, Expect};
use name::AsName; use name::AsName;
use crate::{test_db::TestDB, AstId, AttrId, MacroCallId, MacroCallKind, MacroCallLoc}; use crate::{test_db::TestDB, AstId, MacroCallId, MacroCallKind, MacroCallLoc};
use super::*; use super::*;
@ -320,7 +320,7 @@ $0
kind: MacroCallKind::Derive { kind: MacroCallKind::Derive {
ast_id, ast_id,
derive_name: name.to_string(), derive_name: name.to_string(),
derive_attr: AttrId(0), derive_attr_index: 0,
}, },
}; };

View file

@ -293,12 +293,9 @@ pub struct MacroCallLoc {
#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum MacroCallKind { pub enum MacroCallKind {
FnLike { ast_id: AstId<ast::MacroCall>, fragment: FragmentKind }, FnLike { ast_id: AstId<ast::MacroCall>, fragment: FragmentKind },
Derive { ast_id: AstId<ast::Item>, derive_name: String, derive_attr: AttrId }, Derive { ast_id: AstId<ast::Item>, derive_name: String, derive_attr_index: u32 },
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct AttrId(pub u32);
impl MacroCallKind { impl MacroCallKind {
fn file_id(&self) -> HirFileId { fn file_id(&self) -> HirFileId {
match self { match self {