Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/expr_store/tests/body.rs')
-rw-r--r--crates/hir-def/src/expr_store/tests/body.rs31
1 files changed, 29 insertions, 2 deletions
diff --git a/crates/hir-def/src/expr_store/tests/body.rs b/crates/hir-def/src/expr_store/tests/body.rs
index c31428be28..4a775568bc 100644
--- a/crates/hir-def/src/expr_store/tests/body.rs
+++ b/crates/hir-def/src/expr_store/tests/body.rs
@@ -159,7 +159,7 @@ fn main() {
expect![[r#"
fn main() {
match builtin#lang(into_iter)(
- (0) ..(10) ,
+ 0..10,
) {
mut <ra@gennew>11 => loop {
match builtin#lang(next)(
@@ -580,7 +580,7 @@ const fn f(x: i32) -> i32 {
let MatchArm { pat, .. } = mtch_arms[1];
match body[pat] {
- Pat::Range { start, end } => {
+ Pat::Range { start, end, range_type: _ } => {
let hir_start = &body[start.unwrap()];
let hir_end = &body[end.unwrap()];
@@ -590,3 +590,30 @@ const fn f(x: i32) -> i32 {
_ => {}
}
}
+
+#[test]
+fn print_hir_precedences() {
+ let (db, body, def) = lower(
+ r#"
+fn main() {
+ _ = &(1 - (2 - 3) + 4 * 5 * (6 + 7));
+ _ = 1 + 2 < 3 && true && 4 < 5 && (a || b || c) || d && e;
+ if let _ = 2 && true && let _ = 3 {}
+ break a && b || (return) || (return 2);
+ let r = &2;
+ let _ = &mut (*r as i32)
+}
+"#,
+ );
+
+ expect![[r#"
+ fn main() {
+ _ = &((1 - (2 - 3)) + (4 * 5) * (6 + 7));
+ _ = 1 + 2 < 3 && true && 4 < 5 && (a || b || c) || d && e;
+ if let _ = 2 && true && let _ = 3 {}
+ break a && b || (return) || (return 2);
+ let r = &2;
+ let _ = &mut (*r as i32);
+ }"#]]
+ .assert_eq(&body.pretty_print(&db, def, Edition::CURRENT))
+}