mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +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
|
@ -27,6 +27,7 @@ use std::{iter, mem, ops::Deref, sync::Arc};
|
|||
|
||||
use base_db::{salsa, CrateId};
|
||||
use hir_def::{
|
||||
builtin_type::BuiltinType,
|
||||
expr::ExprId,
|
||||
type_ref::{Mutability, Rawness},
|
||||
AdtId, AssocContainerId, DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId,
|
||||
|
@ -738,6 +739,15 @@ impl Ty {
|
|||
Substs(sig.params_and_return),
|
||||
)
|
||||
}
|
||||
pub fn builtin(builtin: BuiltinType) -> Self {
|
||||
Ty::simple(match builtin {
|
||||
BuiltinType::Char => TypeCtor::Char,
|
||||
BuiltinType::Bool => TypeCtor::Bool,
|
||||
BuiltinType::Str => TypeCtor::Str,
|
||||
BuiltinType::Int(t) => TypeCtor::Int(IntTy::from(t).into()),
|
||||
BuiltinType::Float(t) => TypeCtor::Float(FloatTy::from(t).into()),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn as_reference(&self) -> Option<(&Ty, Mutability)> {
|
||||
match self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue