aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-12 13:18:30 +0000
committerGitHub <[email protected]>2021-02-12 13:18:30 +0000
commitdee5aba43a1b45131bf31268431fa71923f2ef2a (patch)
tree9a43e69bd5591d7e436fe236668d6769f5d500ea /crates/hir_ty/src/lib.rs
parenta044ac980cca07913e64a7c5fab53f7fe7cecb81 (diff)
parente938d769d922feb374967d5b695e3b3baa70a566 (diff)
Merge #7644
7644: Primitive completion r=jonas-schievink a=jonas-schievink Fixes https://github.com/rust-analyzer/rust-analyzer/issues/7642 Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r--crates/hir_ty/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 6bec389f8..50d248674 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -27,6 +27,7 @@ use std::{iter, mem, ops::Deref, sync::Arc};
27 27
28use base_db::{salsa, CrateId}; 28use base_db::{salsa, CrateId};
29use hir_def::{ 29use hir_def::{
30 builtin_type::BuiltinType,
30 expr::ExprId, 31 expr::ExprId,
31 type_ref::{Mutability, Rawness}, 32 type_ref::{Mutability, Rawness},
32 AdtId, AssocContainerId, DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId, 33 AdtId, AssocContainerId, DefWithBodyId, FunctionId, GenericDefId, HasModule, LifetimeParamId,
@@ -738,6 +739,15 @@ impl Ty {
738 Substs(sig.params_and_return), 739 Substs(sig.params_and_return),
739 ) 740 )
740 } 741 }
742 pub fn builtin(builtin: BuiltinType) -> Self {
743 Ty::simple(match builtin {
744 BuiltinType::Char => TypeCtor::Char,
745 BuiltinType::Bool => TypeCtor::Bool,
746 BuiltinType::Str => TypeCtor::Str,
747 BuiltinType::Int(t) => TypeCtor::Int(IntTy::from(t).into()),
748 BuiltinType::Float(t) => TypeCtor::Float(FloatTy::from(t).into()),
749 })
750 }
741 751
742 pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { 752 pub fn as_reference(&self) -> Option<(&Ty, Mutability)> {
743 match self { 753 match self {