aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/item_tree/lower.rs6
-rw-r--r--crates/hir_ty/src/tests/macros.rs26
-rw-r--r--crates/ide/src/syntax_highlighting.rs3
-rw-r--r--crates/ide/src/typing.rs3
-rw-r--r--crates/rust-analyzer/src/handlers.rs3
5 files changed, 40 insertions, 1 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index 8d3862811..124dcc866 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -174,6 +174,12 @@ impl Ctx {
174 let forced_vis = self.forced_visibility.take(); 174 let forced_vis = self.forced_visibility.take();
175 175
176 let mut block_stack = Vec::new(); 176 let mut block_stack = Vec::new();
177
178 // if container itself is block, add it to the stack
179 if let Some(block) = ast::BlockExpr::cast(container.clone()) {
180 block_stack.push(self.source_ast_id_map.ast_id(&block));
181 }
182
177 for event in container.preorder().skip(1) { 183 for event in container.preorder().skip(1) {
178 match event { 184 match event {
179 WalkEvent::Enter(node) => { 185 WalkEvent::Enter(node) => {
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs
index 3eb01dbd0..86e3d8b86 100644
--- a/crates/hir_ty/src/tests/macros.rs
+++ b/crates/hir_ty/src/tests/macros.rs
@@ -373,6 +373,32 @@ fn recursive_inner_item_macro_rules() {
373} 373}
374 374
375#[test] 375#[test]
376fn infer_macro_defining_block_with_items() {
377 check_infer(
378 r#"
379 macro_rules! foo {
380 () => {{
381 fn bar() -> usize { 0 }
382 bar()
383 }};
384 }
385 fn main() {
386 let _a = foo!();
387 }
388 "#,
389 expect![[r#"
390 !15..18 '{0}': usize
391 !16..17 '0': usize
392 !0..24 '{fnbar...bar()}': usize
393 !18..21 'bar': fn bar() -> usize
394 !18..23 'bar()': usize
395 98..122 '{ ...!(); }': ()
396 108..110 '_a': usize
397 "#]],
398 );
399}
400
401#[test]
376fn infer_type_value_macro_having_same_name() { 402fn infer_type_value_macro_having_same_name() {
377 check_infer( 403 check_infer(
378 r#" 404 r#"
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index 67a10766b..9df8d21af 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -48,6 +48,9 @@ pub struct HlRange {
48// 48//
49// The general rule is that a reference to an entity gets colored the same way as the entity itself. 49// The general rule is that a reference to an entity gets colored the same way as the entity itself.
50// We also give special modifier for `mut` and `&mut` local variables. 50// We also give special modifier for `mut` and `&mut` local variables.
51//
52// image::https://user-images.githubusercontent.com/48062697/113164457-06cfb980-9239-11eb-819b-0f93e646acf8.png[]
53// image::https://user-images.githubusercontent.com/48062697/113187625-f7f50100-9250-11eb-825e-91c58f236071.png[]
51pub(crate) fn highlight( 54pub(crate) fn highlight(
52 db: &RootDatabase, 55 db: &RootDatabase,
53 file_id: FileId, 56 file_id: FileId,
diff --git a/crates/ide/src/typing.rs b/crates/ide/src/typing.rs
index e10b7d98e..11408d445 100644
--- a/crates/ide/src/typing.rs
+++ b/crates/ide/src/typing.rs
@@ -49,6 +49,9 @@ pub(crate) const TRIGGER_CHARS: &str = ".=>";
49// ---- 49// ----
50// "editor.formatOnType": true, 50// "editor.formatOnType": true,
51// ---- 51// ----
52//
53// image::https://user-images.githubusercontent.com/48062697/113166163-69758500-923a-11eb-81ee-eb33ec380399.gif[]
54// image::https://user-images.githubusercontent.com/48062697/113171066-105c2000-923f-11eb-87ab-f4a263346567.gif[]
52pub(crate) fn on_char_typed( 55pub(crate) fn on_char_typed(
53 db: &RootDatabase, 56 db: &RootDatabase,
54 position: FilePosition, 57 position: FilePosition,
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 85e67554c..53d29ddfc 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -84,7 +84,8 @@ pub(crate) fn handle_analyzer_status(
84 84
85pub(crate) fn handle_memory_usage(state: &mut GlobalState, _: ()) -> Result<String> { 85pub(crate) fn handle_memory_usage(state: &mut GlobalState, _: ()) -> Result<String> {
86 let _p = profile::span("handle_memory_usage"); 86 let _p = profile::span("handle_memory_usage");
87 let mem = state.analysis_host.per_query_memory_usage(); 87 let mut mem = state.analysis_host.per_query_memory_usage();
88 mem.push(("Remaining".into(), profile::memory_usage().allocated));
88 89
89 let mut out = String::new(); 90 let mut out = String::new();
90 for (name, bytes) in mem { 91 for (name, bytes) in mem {