Skip to content

Commit aee0e30

Browse files
committed
feat: add inlay hint support for block expr with lifetime label
1 parent b939d3b commit aee0e30

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/tools/rust-analyzer/crates/ide/src/inlay_hints/closing_brace.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(super) fn hints(
1818
sema: &Semantics<'_, RootDatabase>,
1919
config: &InlayHintsConfig,
2020
file_id: EditionedFileId,
21-
node: SyntaxNode,
21+
mut node: SyntaxNode,
2222
) -> Option<()> {
2323
let min_lines = config.closing_brace_hints_min_lines?;
2424

@@ -52,6 +52,13 @@ pub(super) fn hints(
5252

5353
let module = ast::Module::cast(list.syntax().parent()?)?;
5454
(format!("mod {}", module.name()?), module.name().map(name))
55+
} else if let Some(label) = ast::Label::cast(node.clone()) {
56+
// in this case, `ast::Label` could be seen as a part of `ast::BlockExpr`, to respect the `min_lines` config
57+
node = node.parent()?;
58+
let block = label.syntax().parent().and_then(ast::BlockExpr::cast)?;
59+
closing_token = block.stmt_list()?.r_curly_token()?;
60+
let lifetime = label.lifetime().map_or_else(String::new, |it| it.to_string());
61+
(lifetime, Some(label.syntax().text_range()))
5562
} else if let Some(block) = ast::BlockExpr::cast(node.clone()) {
5663
closing_token = block.stmt_list()?.r_curly_token()?;
5764

0 commit comments

Comments
 (0)