Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer/expr.rs')
| -rw-r--r-- | crates/hir-ty/src/infer/expr.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs index 555a9fae48..06742f7b36 100644 --- a/crates/hir-ty/src/infer/expr.rs +++ b/crates/hir-ty/src/infer/expr.rs @@ -9,7 +9,8 @@ use chalk_ir::{cast::Cast, fold::Shift, DebruijnIndex, Mutability, TyVariableKin use hir_def::{ generics::TypeOrConstParamData, hir::{ - ArithOp, Array, BinaryOp, ClosureKind, Expr, ExprId, LabelId, Literal, Statement, UnaryOp, + format_args::FormatArgumentKind, ArithOp, Array, BinaryOp, ClosureKind, Expr, ExprId, + LabelId, Literal, Statement, UnaryOp, }, lang_item::{LangItem, LangItemTarget}, path::{GenericArg, GenericArgs}, @@ -848,6 +849,25 @@ impl InferenceContext<'_> { self.infer_expr_no_expect(it.e); self.result.standard_types.unit.clone() } + Expr::FormatArgs(fa) => { + fa.arguments + .arguments + .iter() + .filter(|it| !matches!(it.kind, FormatArgumentKind::Captured(_))) + .for_each(|it| _ = self.infer_expr_no_expect(it.expr)); + + match self + .resolve_lang_item(LangItem::FormatArguments) + .and_then(|it| it.as_struct()) + { + Some(s) => { + // NOTE: This struct has a lifetime parameter, but we don't currently emit + // those to chalk + TyKind::Adt(AdtId(s.into()), Substitution::empty(Interner)).intern(Interner) + } + None => self.err_ty(), + } + } }; // use a new type variable if we got unknown here let ty = self.insert_type_vars_shallow(ty); |