about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-07-01 15:04:58 +0200
committerLukas Wirth <lukastw97@gmail.com>2022-07-01 15:21:55 +0200
commit9165e3b3810f7f602edc4977bf032a5cd53378cc (patch)
tree1930bc7c277dfb720e8adc30dd312c16703118c3
parent531e1523908c7f2201ad3c877ede48a3faec14be (diff)
downloadrust-9165e3b3810f7f602edc4977bf032a5cd53378cc.tar.gz
rust-9165e3b3810f7f602edc4977bf032a5cd53378cc.zip
Update hir-ty test outputs
-rw-r--r--crates/hir-def/src/body/lower.rs1
-rw-r--r--crates/hir-def/src/body/scope.rs3
-rw-r--r--crates/hir-ty/src/tests/macros.rs23
-rw-r--r--crates/hir-ty/src/tests/regression.rs7
4 files changed, 20 insertions, 14 deletions
diff --git a/crates/hir-def/src/body/lower.rs b/crates/hir-def/src/body/lower.rs
index 409193b269f..e188d80eb81 100644
--- a/crates/hir-def/src/body/lower.rs
+++ b/crates/hir-def/src/body/lower.rs
@@ -631,7 +631,6 @@ impl ExprCollector<'_> {
                     let mac_call = mac.macro_call()?;
                     let syntax_ptr = AstPtr::new(expr);
                     let macro_ptr = AstPtr::new(&mac_call);
-                    // let prev_stmt = self.statements_in_scope.len();
                     let stmt = self.collect_macro_call(
                         mac_call,
                         macro_ptr,
diff --git a/crates/hir-def/src/body/scope.rs b/crates/hir-def/src/body/scope.rs
index c9ab19e59bc..019c10712b5 100644
--- a/crates/hir-def/src/body/scope.rs
+++ b/crates/hir-def/src/body/scope.rs
@@ -175,6 +175,9 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
 
     scopes.set_scope(expr, *scope);
     match &body[expr] {
+        Expr::MacroStmts { statements, tail } => {
+            compute_block_scopes(statements, *tail, body, scopes, *scope);
+        }
         Expr::Block { statements, tail, id, label } => {
             let scope = scopes.new_block_scope(*scope, *id, make_label(label));
             // Overwrite the old scope for the block expr, so that every block scope can be found
diff --git a/crates/hir-ty/src/tests/macros.rs b/crates/hir-ty/src/tests/macros.rs
index a61175f2733..5a3cde028da 100644
--- a/crates/hir-ty/src/tests/macros.rs
+++ b/crates/hir-ty/src/tests/macros.rs
@@ -191,6 +191,8 @@ fn expr_macro_def_expanded_in_various_places() {
             !0..6 '1isize': isize
             !0..6 '1isize': isize
             !0..6 '1isize': isize
+            !0..6 '1isize': isize
+            !0..6 '1isize': isize
             39..442 '{     ...!(); }': ()
             73..94 'spam!(...am!())': {unknown}
             100..119 'for _ ...!() {}': ()
@@ -272,6 +274,8 @@ fn expr_macro_rules_expanded_in_various_places() {
             !0..6 '1isize': isize
             !0..6 '1isize': isize
             !0..6 '1isize': isize
+            !0..6 '1isize': isize
+            !0..6 '1isize': isize
             53..456 '{     ...!(); }': ()
             87..108 'spam!(...am!())': {unknown}
             114..133 'for _ ...!() {}': ()
@@ -307,7 +311,6 @@ fn expr_macro_expanded_in_stmts() {
         "#,
         expect![[r#"
             !0..8 'leta=();': ()
-            !0..8 'leta=();': ()
             !3..4 'a': ()
             !5..7 '()': ()
             57..84 '{     ...); } }': ()
@@ -335,16 +338,16 @@ fn recurisve_macro_expanded_in_stmts() {
         }
         "#,
         expect![[r#"
-            !0..7 'leta=3;': {unknown}
-            !0..7 'leta=3;': {unknown}
-            !0..13 'ng!{[leta=3]}': {unknown}
-            !0..13 'ng!{[leta=]3}': {unknown}
-            !0..13 'ng!{[leta]=3}': {unknown}
+            !0..7 'leta=3;': ()
+            !0..13 'ng!{[leta=3]}': ()
+            !0..13 'ng!{[leta=]3}': ()
+            !0..13 'ng!{[leta]=3}': ()
+            !0..13 'ng!{[let]a=3}': ()
             !3..4 'a': i32
             !5..6 '3': i32
             196..237 '{     ...= a; }': ()
-            229..230 'b': i32
-            233..234 'a': i32
+            229..230 'b': {unknown}
+            233..234 'a': {unknown}
         "#]],
     );
 }
@@ -364,8 +367,8 @@ fn recursive_inner_item_macro_rules() {
         "#,
         expect![[r#"
             !0..1 '1': i32
-            !0..26 'macro_...>{1};}': {unknown}
-            !0..26 'macro_...>{1};}': {unknown}
+            !0..7 'mac!($)': ()
+            !0..26 'macro_...>{1};}': ()
             107..143 '{     ...!(); }': ()
             129..130 'a': i32
         "#]],
diff --git a/crates/hir-ty/src/tests/regression.rs b/crates/hir-ty/src/tests/regression.rs
index 93f765f703c..d41470d29f7 100644
--- a/crates/hir-ty/src/tests/regression.rs
+++ b/crates/hir-ty/src/tests/regression.rs
@@ -573,6 +573,7 @@ fn issue_6811() {
         }
         "#,
         expect![[r#"
+            !0..16 'let_a=...t_b=1;': ()
             !3..5 '_a': i32
             !6..7 '1': i32
             !11..13 '_b': i32
@@ -1012,17 +1013,17 @@ fn cfg_tail() {
         "#,
         expect![[r#"
             14..53 '{     ...)] 9 }': ()
-            20..31 '{ "first" }': ()
+            20..31 '{ "first" }': &str
             22..29 '"first"': &str
             72..190 '{     ...] 13 }': ()
             78..88 '{ "fake" }': &str
             80..86 '"fake"': &str
             93..103 '{ "fake" }': &str
             95..101 '"fake"': &str
-            108..120 '{ "second" }': ()
+            108..120 '{ "second" }': &str
             110..118 '"second"': &str
             210..273 '{     ... 15; }': ()
-            216..227 '{ "third" }': ()
+            216..227 '{ "third" }': &str
             218..225 '"third"': &str
             293..357 '{     ...] 15 }': ()
             299..311 '{ "fourth" }': &str