Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/mir/lower.rs')
-rw-r--r--crates/hir-ty/src/mir/lower.rs29
1 files changed, 11 insertions, 18 deletions
diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs
index 1d1044df6e..f88696692e 100644
--- a/crates/hir-ty/src/mir/lower.rs
+++ b/crates/hir-ty/src/mir/lower.rs
@@ -5,11 +5,11 @@ use std::{fmt::Write, iter, mem};
use base_db::ra_salsa::Cycle;
use chalk_ir::{BoundVar, ConstData, DebruijnIndex, TyKind};
use hir_def::{
- body::{Body, HygieneId},
data::adt::{StructKind, VariantData},
+ expr_store::{Body, HygieneId},
hir::{
- ArithOp, Array, BinaryOp, BindingAnnotation, BindingId, ExprId, LabelId, Literal,
- LiteralOrConst, MatchArm, Pat, PatId, RecordFieldPat, RecordLitField,
+ ArithOp, Array, BinaryOp, BindingAnnotation, BindingId, ExprId, LabelId, Literal, MatchArm,
+ Pat, PatId, RecordFieldPat, RecordLitField,
},
lang_item::{LangItem, LangItemTarget},
path::Path,
@@ -1358,20 +1358,10 @@ impl<'ctx> MirLowerCtx<'ctx> {
Ok(())
}
- fn lower_literal_or_const_to_operand(
- &mut self,
- ty: Ty,
- loc: &LiteralOrConst,
- ) -> Result<Operand> {
- match loc {
- LiteralOrConst::Literal(l) => self.lower_literal_to_operand(ty, l),
- LiteralOrConst::Const(c) => {
- let c = match &self.body.pats[*c] {
- Pat::Path(p) => p,
- _ => not_supported!(
- "only `char` and numeric types are allowed in range patterns"
- ),
- };
+ fn lower_literal_or_const_to_operand(&mut self, ty: Ty, loc: &ExprId) -> Result<Operand> {
+ match &self.body.exprs[*loc] {
+ Expr::Literal(l) => self.lower_literal_to_operand(ty, l),
+ Expr::Path(c) => {
let edition = self.edition();
let unresolved_name =
|| MirLowerError::unresolved_path(self.db, c, edition, &self.body.types);
@@ -1392,6 +1382,9 @@ impl<'ctx> MirLowerCtx<'ctx> {
}
}
}
+ _ => {
+ not_supported!("only `char` and numeric types are allowed in range patterns");
+ }
}
}
@@ -2156,7 +2149,7 @@ pub fn lower_to_mir(
// need to take this input explicitly.
root_expr: ExprId,
) -> Result<MirBody> {
- if infer.has_errors {
+ if infer.type_mismatches().next().is_some() {
return Err(MirLowerError::HasErrors);
}
let mut ctx = MirLowerCtx::new(db, owner, body, infer);