fix: mir for range pattern

This commit is contained in:
roife 2024-03-05 19:30:41 +08:00
parent ece18fecfa
commit 96a7c6ae3c

View file

@ -1364,10 +1364,14 @@ impl<'ctx> MirLowerCtx<'ctx> {
match loc {
LiteralOrConst::Literal(l) => self.lower_literal_to_operand(ty, l),
LiteralOrConst::Const(c) => {
let unresolved_name = || MirLowerError::unresolved_path(self.db, c);
let c = match &self.body.pats[*c] {
Pat::Path(p) => p,
_ => not_supported!("only `char` and numeric types are allowed in range patterns"),
};
let unresolved_name = || MirLowerError::unresolved_path(self.db, c.as_ref());
let resolver = self.owner.resolver(self.db.upcast());
let pr = resolver
.resolve_path_in_value_ns(self.db.upcast(), c)
.resolve_path_in_value_ns(self.db.upcast(), c.as_ref())
.ok_or_else(unresolved_name)?;
match pr {
ResolveValueResult::ValueNs(v, _) => {