From cf3b4f1e208247c9d171273dabff9c6b3c98a240 Mon Sep 17 00:00:00 2001 From: cynecx Date: Sat, 10 Apr 2021 17:49:12 +0200 Subject: hir_ty: Expand macros at type position --- crates/parser/src/grammar/types.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'crates/parser') diff --git a/crates/parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs index 94cbf7d85..6ae3e734f 100644 --- a/crates/parser/src/grammar/types.rs +++ b/crates/parser/src/grammar/types.rs @@ -283,17 +283,21 @@ pub(super) fn path_type(p: &mut Parser) { // type B = crate::foo!(); fn path_or_macro_type_(p: &mut Parser, allow_bounds: bool) { assert!(paths::is_path_start(p)); + let r = p.start(); let m = p.start(); + paths::type_path(p); let kind = if p.at(T![!]) && !p.at(T![!=]) { items::macro_call_after_excl(p); - MACRO_CALL + m.complete(p, MACRO_CALL); + MACRO_TYPE } else { + m.abandon(p); PATH_TYPE }; - let path = m.complete(p, kind); + let path = r.complete(p, kind); if allow_bounds { opt_type_bounds_as_dyn_trait_type(p, path); @@ -319,7 +323,7 @@ pub(super) fn path_type_(p: &mut Parser, allow_bounds: bool) { fn opt_type_bounds_as_dyn_trait_type(p: &mut Parser, type_marker: CompletedMarker) { assert!(matches!( type_marker.kind(), - SyntaxKind::PATH_TYPE | SyntaxKind::FOR_TYPE | SyntaxKind::MACRO_CALL + SyntaxKind::PATH_TYPE | SyntaxKind::FOR_TYPE | SyntaxKind::MACRO_TYPE )); if !p.at(T![+]) { return; -- cgit v1.2.3