Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8a18dce

Browse files
committed
Add a test to monitor whats going on
1 parent 31a5685 commit 8a18dce

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed

src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ use crate::{
4444
FormatPlaceholder, FormatSign, FormatTrait,
4545
},
4646
Array, Binding, BindingAnnotation, BindingId, BindingProblems, CaptureBy, ClosureKind,
47-
Expr, ExprId, Item, Label, LabelId, Literal, LiteralOrConst, MatchArm, Movability,
48-
OffsetOf, Pat, PatId, RecordFieldPat, RecordLitField, Statement,
47+
Expr, ExprId, Item, Label, LabelId, Literal, MatchArm, Movability, OffsetOf, Pat, PatId,
48+
RecordFieldPat, RecordLitField, Statement,
4949
},
5050
item_scope::BuiltinShadowMode,
5151
lang_item::LangItem,
@@ -1802,10 +1802,15 @@ impl ExprCollector<'_> {
18021802
ptr,
18031803
))
18041804
}
1805-
pat @ (ast::Pat::IdentPat(_) | ast::Pat::PathPat(_)) => {
1806-
// let subpat = self.collect_pat(pat.clone(), binding_list);
1807-
// Some(Box::new(LiteralOrConst::Const(subpat)))
1808-
// TODO
1805+
ast::Pat::IdentPat(_) => Some(self.missing_expr()),
1806+
ast::Pat::PathPat(p) => {
1807+
if let Some(path) = p.path() {
1808+
if let Some(parsed) = self.parse_path(path) {
1809+
return Some(
1810+
self.alloc_expr_from_pat(Expr::Path(parsed), ptr),
1811+
);
1812+
}
1813+
}
18091814
Some(self.missing_expr())
18101815
}
18111816
_ => None,

src/tools/rust-analyzer/crates/hir-def/src/expr_store/tests.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,46 @@ async fn foo(a: (), b: i32) -> u32 {
460460
expect!["fn foo(�: (), �: i32) -> impl ::core::future::Future::<Output = u32> �"]
461461
.assert_eq(&printed);
462462
}
463+
464+
fn abc() {
465+
let (db, body, owner) = lower(
466+
r#"
467+
pub const L: i32 = 6;
468+
mod x {
469+
pub const R: i32 = 100;
470+
}
471+
const fn f(x: i32) -> i32 {
472+
match x {
473+
-1..=5 => x * 10,
474+
L..=x::R => x * 100,
475+
_ => x,
476+
}
477+
}"#,
478+
);
479+
480+
for (pat_id, pat) in body.pats.iter() {
481+
match pat {
482+
Pat::Range { start, end } => {
483+
let pretty = body.pretty_print_pat(&db, owner, pat_id, false, Edition::Edition2021);
484+
eprintln!("RANGE {}", pretty);
485+
486+
if let Some(start) = start {
487+
eprintln!("START");
488+
let expr = body.exprs[*start].clone();
489+
dbg!(expr);
490+
} else {
491+
eprintln!("START is None");
492+
}
493+
494+
if let Some(end) = end {
495+
eprintln!("END");
496+
let expr = body.exprs[*end].clone();
497+
dbg!(expr);
498+
} else {
499+
eprintln!("END is None");
500+
}
501+
}
502+
_ => {}
503+
}
504+
}
505+
}

0 commit comments

Comments
 (0)