Skip to content

Commit 740a864

Browse files
author
luoyangze.ptrl
committed
feat: skip checking tt count for include macro call
1 parent 2f6961a commit 740a864

File tree

1 file changed

+19
-3
lines changed
  • crates/hir-expand/src

1 file changed

+19
-3
lines changed

crates/hir-expand/src/db.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,25 @@ fn macro_expand(db: &dyn ExpandDatabase, id: MacroCallId) -> ExpandResult<Arc<tt
614614
err = error.clone().or(err);
615615
}
616616

617-
// Set a hard limit for the expanded tt
618-
if let Err(value) = check_tt_count(&tt) {
619-
return value;
617+
// Skip checking token tree limit for include! macro call
618+
let skip_check_tt_count = match loc.kind {
619+
MacroCallKind::FnLike { ast_id, expand_to: _ } => {
620+
if let Some(name_ref) =
621+
ast_id.to_node(db).path().and_then(|p| p.segment()).and_then(|s| s.name_ref())
622+
{
623+
name_ref.text() == "include"
624+
} else {
625+
false
626+
}
627+
}
628+
_ => false,
629+
};
630+
631+
if !skip_check_tt_count {
632+
// Set a hard limit for the expanded tt
633+
if let Err(value) = check_tt_count(&tt) {
634+
return value;
635+
}
620636
}
621637

622638
ExpandResult { value: Arc::new(tt), err }

0 commit comments

Comments
 (0)