mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Wrap BuiltinType
in code model
This commit is contained in:
parent
b0f20a795d
commit
216dc856c5
9 changed files with 56 additions and 28 deletions
|
@ -6,7 +6,6 @@ use base_db::{CrateDisplayName, CrateId, Edition, FileId};
|
|||
use either::Either;
|
||||
use hir_def::{
|
||||
adt::{ReprKind, StructKind, VariantData},
|
||||
builtin_type::BuiltinType,
|
||||
expr::{BindingAnnotation, LabelId, Pat, PatId},
|
||||
import_map,
|
||||
item_tree::ItemTreeNode,
|
||||
|
@ -245,7 +244,7 @@ impl ModuleDef {
|
|||
ModuleDef::Const(it) => it.name(db),
|
||||
ModuleDef::Static(it) => it.name(db),
|
||||
|
||||
ModuleDef::BuiltinType(it) => Some(it.as_name()),
|
||||
ModuleDef::BuiltinType(it) => Some(it.name()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -994,6 +993,23 @@ impl HasVisibility for TypeAlias {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct BuiltinType {
|
||||
pub(crate) inner: hir_def::builtin_type::BuiltinType,
|
||||
}
|
||||
|
||||
impl BuiltinType {
|
||||
pub fn ty(self, db: &dyn HirDatabase, module: Module) -> Type {
|
||||
let resolver = module.id.resolver(db.upcast());
|
||||
Type::new_with_resolver(db, &resolver, Ty::builtin(self.inner))
|
||||
.expect("crate not present in resolver")
|
||||
}
|
||||
|
||||
pub fn name(self) -> Name {
|
||||
self.inner.as_name()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct MacroDef {
|
||||
pub(crate) id: MacroDefId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue