From ca62d98781f13b6fb82c4d19269ee255208fb3d4 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 11 Jan 2020 00:29:00 +0800 Subject: Expand PAREN_EXPR as expression --- crates/ra_hir_expand/src/db.rs | 1 + crates/ra_hir_ty/src/tests/regression.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'crates') diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index 2e12e126f..d41b34161 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -187,6 +187,7 @@ fn to_fragment_kind(db: &dyn AstDatabase, macro_call_id: MacroCallId) -> Fragmen ARG_LIST => FragmentKind::Expr, TRY_EXPR => FragmentKind::Expr, TUPLE_EXPR => FragmentKind::Expr, + PAREN_EXPR => FragmentKind::Expr, ITEM_LIST => FragmentKind::Items, _ => { // Unknown , Just guess it is `Items` diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs index 13c5f62e4..6c5d39549 100644 --- a/crates/ra_hir_ty/src/tests/regression.rs +++ b/crates/ra_hir_ty/src/tests/regression.rs @@ -309,6 +309,23 @@ fn test(query_response: Canonical>) { ); } +#[test] +fn infer_paren_macro_call() { + assert_snapshot!( + infer(r#" +macro_rules! bar { () => {0u32} } +fn test() { + let a = (bar!()); +} +"#), + @r###" + ![0; 4) '0u32': u32 + [45; 70) '{ ...()); }': () + [55; 56) 'a': u32 + "### + ); +} + #[test] fn bug_1030() { assert_snapshot!(infer(r#" -- cgit v1.2.3