mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Semantic getter
This commit is contained in:
parent
6c7526d308
commit
98676efdc5
9 changed files with 401 additions and 63 deletions
|
@ -1574,6 +1574,11 @@ pub struct BuiltinType {
|
|||
}
|
||||
|
||||
impl BuiltinType {
|
||||
// FIXME: I'm not sure if it's the best place to put it
|
||||
pub fn str() -> BuiltinType {
|
||||
BuiltinType { inner: hir_def::builtin_type::BuiltinType::Str }
|
||||
}
|
||||
|
||||
pub fn ty(self, db: &dyn HirDatabase, module: Module) -> Type {
|
||||
let resolver = module.id.resolver(db.upcast());
|
||||
Type::new_with_resolver(db, &resolver, TyBuilder::builtin(self.inner))
|
||||
|
@ -2263,6 +2268,11 @@ impl Type {
|
|||
Type::new(db, krate, def, ty)
|
||||
}
|
||||
|
||||
// FIXME: No idea where to put it
|
||||
pub fn make_slice_of(self) -> Type {
|
||||
Type { krate: self.krate, env: self.env, ty: TyBuilder::slice(self.ty) }
|
||||
}
|
||||
|
||||
pub fn is_unit(&self) -> bool {
|
||||
matches!(self.ty.kind(&Interner), TyKind::Tuple(0, ..))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue