Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/hir-def/src/attrs.rs | 3 | ||||
| -rw-r--r-- | crates/ide/src/hover/tests.rs | 41 |
2 files changed, 44 insertions, 0 deletions
diff --git a/crates/hir-def/src/attrs.rs b/crates/hir-def/src/attrs.rs index 3bf7090436..a5bc283330 100644 --- a/crates/hir-def/src/attrs.rs +++ b/crates/hir-def/src/attrs.rs @@ -852,6 +852,9 @@ fn expand_doc_expr_via_macro_pipeline<'db>( expr: ast::Expr, ) -> Option<String> { match expr { + ast::Expr::ParenExpr(paren_expr) => { + expand_doc_expr_via_macro_pipeline(expander, source_ctx, paren_expr.expr()?) + } ast::Expr::Literal(literal) => match literal.kind() { ast::LiteralKind::String(string) => string.value().ok().map(Into::into), _ => None, diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 63af9a31fb..a57db032db 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -11448,6 +11448,47 @@ fn foo() { let bar = Bar; bar.fo$0o(); } } #[test] +fn test_hover_doc_attr_macro_argument_expr_issue_7688() { + check( + r#" +#[rustc_builtin_macro] +macro_rules! concat {} + +macro_rules! doc_comment { + ($x:expr, $($tt:tt)*) => { + #[doc = $x] + $($tt)* + }; +} + +doc_comment! { + concat!("Hello", " world"), + struct Ba$0r; +} +"#, + expect![[r#" + *Bar* + + ```rust + ra_test_fixture + ``` + + ```rust + struct Bar + ``` + + --- + + size = 0, align = 1, no Drop + + --- + + Hello world + "#]], + ); +} + +#[test] fn test_hover_doc_attr_concat_macro() { check( r#" |