Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/term_search/expr.rs')
-rw-r--r--crates/hir/src/term_search/expr.rs33
1 files changed, 19 insertions, 14 deletions
diff --git a/crates/hir/src/term_search/expr.rs b/crates/hir/src/term_search/expr.rs
index 78ee3b5aa6..843831948a 100644
--- a/crates/hir/src/term_search/expr.rs
+++ b/crates/hir/src/term_search/expr.rs
@@ -59,7 +59,7 @@ fn mod_item_path_str(
/// So in short it pretty much gives us a way to get type `Option<i32>` using the items we have in
/// scope.
#[derive(Debug, Clone, Eq, Hash, PartialEq)]
-pub enum Expr {
+pub enum Expr<'db> {
/// Constant
Const(Const),
/// Static variable
@@ -69,26 +69,31 @@ pub enum Expr {
/// Constant generic parameter
ConstParam(ConstParam),
/// Well known type (such as `true` for bool)
- FamousType { ty: Type, value: &'static str },
+ FamousType { ty: Type<'db>, value: &'static str },
/// Function call (does not take self param)
- Function { func: Function, generics: Vec<Type>, params: Vec<Expr> },
+ Function { func: Function, generics: Vec<Type<'db>>, params: Vec<Expr<'db>> },
/// Method call (has self param)
- Method { func: Function, generics: Vec<Type>, target: Box<Expr>, params: Vec<Expr> },
+ Method {
+ func: Function,
+ generics: Vec<Type<'db>>,
+ target: Box<Expr<'db>>,
+ params: Vec<Expr<'db>>,
+ },
/// Enum variant construction
- Variant { variant: Variant, generics: Vec<Type>, params: Vec<Expr> },
+ Variant { variant: Variant, generics: Vec<Type<'db>>, params: Vec<Expr<'db>> },
/// Struct construction
- Struct { strukt: Struct, generics: Vec<Type>, params: Vec<Expr> },
+ Struct { strukt: Struct, generics: Vec<Type<'db>>, params: Vec<Expr<'db>> },
/// Tuple construction
- Tuple { ty: Type, params: Vec<Expr> },
+ Tuple { ty: Type<'db>, params: Vec<Expr<'db>> },
/// Struct field access
- Field { expr: Box<Expr>, field: Field },
+ Field { expr: Box<Expr<'db>>, field: Field },
/// Passing type as reference (with `&`)
- Reference(Box<Expr>),
+ Reference(Box<Expr<'db>>),
/// Indicates possibility of many different options that all evaluate to `ty`
- Many(Type),
+ Many(Type<'db>),
}
-impl Expr {
+impl<'db> Expr<'db> {
/// Generate source code for type tree.
///
/// Note that trait imports are not added to generated code.
@@ -96,8 +101,8 @@ impl Expr {
/// by `traits_used` method are also imported.
pub fn gen_source_code(
&self,
- sema_scope: &SemanticsScope<'_>,
- many_formatter: &mut dyn FnMut(&Type) -> String,
+ sema_scope: &SemanticsScope<'db>,
+ many_formatter: &mut dyn FnMut(&Type<'db>) -> String,
cfg: ImportPathConfig,
display_target: DisplayTarget,
) -> Result<String, DisplaySourceCodeError> {
@@ -298,7 +303,7 @@ impl Expr {
/// Get type of the type tree.
///
/// Same as getting the type of root node
- pub fn ty(&self, db: &dyn HirDatabase) -> Type {
+ pub fn ty(&self, db: &'db dyn HirDatabase) -> Type<'db> {
match self {
Expr::Const(it) => it.ty(db),
Expr::Static(it) => it.ty(db),