mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Add a test to monitor whats going on
This commit is contained in:
parent
d8779b4a0e
commit
94b00c210c
2 changed files with 54 additions and 6 deletions
|
|
@ -44,8 +44,8 @@ use crate::{
|
||||||
FormatPlaceholder, FormatSign, FormatTrait,
|
FormatPlaceholder, FormatSign, FormatTrait,
|
||||||
},
|
},
|
||||||
Array, Binding, BindingAnnotation, BindingId, BindingProblems, CaptureBy, ClosureKind,
|
Array, Binding, BindingAnnotation, BindingId, BindingProblems, CaptureBy, ClosureKind,
|
||||||
Expr, ExprId, Item, Label, LabelId, Literal, LiteralOrConst, MatchArm, Movability,
|
Expr, ExprId, Item, Label, LabelId, Literal, MatchArm, Movability, OffsetOf, Pat, PatId,
|
||||||
OffsetOf, Pat, PatId, RecordFieldPat, RecordLitField, Statement,
|
RecordFieldPat, RecordLitField, Statement,
|
||||||
},
|
},
|
||||||
item_scope::BuiltinShadowMode,
|
item_scope::BuiltinShadowMode,
|
||||||
lang_item::LangItem,
|
lang_item::LangItem,
|
||||||
|
|
@ -1802,10 +1802,15 @@ impl ExprCollector<'_> {
|
||||||
ptr,
|
ptr,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
pat @ (ast::Pat::IdentPat(_) | ast::Pat::PathPat(_)) => {
|
ast::Pat::IdentPat(_) => Some(self.missing_expr()),
|
||||||
// let subpat = self.collect_pat(pat.clone(), binding_list);
|
ast::Pat::PathPat(p) => {
|
||||||
// Some(Box::new(LiteralOrConst::Const(subpat)))
|
if let Some(path) = p.path() {
|
||||||
// TODO
|
if let Some(parsed) = self.parse_path(path) {
|
||||||
|
return Some(
|
||||||
|
self.alloc_expr_from_pat(Expr::Path(parsed), ptr),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some(self.missing_expr())
|
Some(self.missing_expr())
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
||||||
|
|
@ -460,3 +460,46 @@ async fn foo(a: (), b: i32) -> u32 {
|
||||||
expect!["fn foo(<28>: (), <20>: i32) -> impl ::core::future::Future::<Output = u32> <20>"]
|
expect!["fn foo(<28>: (), <20>: i32) -> impl ::core::future::Future::<Output = u32> <20>"]
|
||||||
.assert_eq(&printed);
|
.assert_eq(&printed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn abc() {
|
||||||
|
let (db, body, owner) = lower(
|
||||||
|
r#"
|
||||||
|
pub const L: i32 = 6;
|
||||||
|
mod x {
|
||||||
|
pub const R: i32 = 100;
|
||||||
|
}
|
||||||
|
const fn f(x: i32) -> i32 {
|
||||||
|
match x {
|
||||||
|
-1..=5 => x * 10,
|
||||||
|
L..=x::R => x * 100,
|
||||||
|
_ => x,
|
||||||
|
}
|
||||||
|
}"#,
|
||||||
|
);
|
||||||
|
|
||||||
|
for (pat_id, pat) in body.pats.iter() {
|
||||||
|
match pat {
|
||||||
|
Pat::Range { start, end } => {
|
||||||
|
let pretty = body.pretty_print_pat(&db, owner, pat_id, false, Edition::Edition2021);
|
||||||
|
eprintln!("RANGE {}", pretty);
|
||||||
|
|
||||||
|
if let Some(start) = start {
|
||||||
|
eprintln!("START");
|
||||||
|
let expr = body.exprs[*start].clone();
|
||||||
|
dbg!(expr);
|
||||||
|
} else {
|
||||||
|
eprintln!("START is None");
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(end) = end {
|
||||||
|
eprintln!("END");
|
||||||
|
let expr = body.exprs[*end].clone();
|
||||||
|
dbg!(expr);
|
||||||
|
} else {
|
||||||
|
eprintln!("END is None");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue