Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-def/src/body/lower.rs12
-rw-r--r--crates/hir-def/src/body/pretty.rs2
-rw-r--r--crates/hir-def/src/hir.rs2
3 files changed, 5 insertions, 11 deletions
diff --git a/crates/hir-def/src/body/lower.rs b/crates/hir-def/src/body/lower.rs
index c9300898b3..18a6c5c2cd 100644
--- a/crates/hir-def/src/body/lower.rs
+++ b/crates/hir-def/src/body/lower.rs
@@ -1413,16 +1413,10 @@ impl ExprCollector<'_> {
ast::Pat::LiteralPat(it) => {
Some(Box::new(LiteralOrConst::Literal(pat_literal_to_hir(it)?.0)))
}
- ast::Pat::IdentPat(p) => {
- let name =
- p.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
- Some(Box::new(LiteralOrConst::Const(name.into())))
+ pat @ (ast::Pat::IdentPat(_) | ast::Pat::PathPat(_)) => {
+ let subpat = self.collect_pat(pat.clone(), binding_list);
+ Some(Box::new(LiteralOrConst::Const(subpat)))
}
- ast::Pat::PathPat(p) => p
- .path()
- .and_then(|path| self.expander.parse_path(self.db, path))
- .map(LiteralOrConst::Const)
- .map(Box::new),
_ => None,
})
};
diff --git a/crates/hir-def/src/body/pretty.rs b/crates/hir-def/src/body/pretty.rs
index cd14f7b855..b2aab55a6a 100644
--- a/crates/hir-def/src/body/pretty.rs
+++ b/crates/hir-def/src/body/pretty.rs
@@ -635,7 +635,7 @@ impl Printer<'_> {
fn print_literal_or_const(&mut self, literal_or_const: &LiteralOrConst) {
match literal_or_const {
LiteralOrConst::Literal(l) => self.print_literal(l),
- LiteralOrConst::Const(c) => self.print_path(c),
+ LiteralOrConst::Const(c) => self.print_pat(*c),
}
}
diff --git a/crates/hir-def/src/hir.rs b/crates/hir-def/src/hir.rs
index 34b2910b4f..ac0caaf0dc 100644
--- a/crates/hir-def/src/hir.rs
+++ b/crates/hir-def/src/hir.rs
@@ -101,7 +101,7 @@ pub enum Literal {
/// Used in range patterns.
pub enum LiteralOrConst {
Literal(Literal),
- Const(Path),
+ Const(PatId),
}
impl Literal {