Unnamed repository; edit this file 'description' to name the repository.
feat: skip checking tt count for include macro call
luoyangze.ptrl 2023-11-01
parent 2f6961a · commit 740a864
-rw-r--r--crates/hir-expand/src/db.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/crates/hir-expand/src/db.rs b/crates/hir-expand/src/db.rs
index 5292a5fa1b..80450afc33 100644
--- a/crates/hir-expand/src/db.rs
+++ b/crates/hir-expand/src/db.rs
@@ -614,9 +614,25 @@ fn macro_expand(db: &dyn ExpandDatabase, id: MacroCallId) -> ExpandResult<Arc<tt
err = error.clone().or(err);
}
- // Set a hard limit for the expanded tt
- if let Err(value) = check_tt_count(&tt) {
- return value;
+ // Skip checking token tree limit for include! macro call
+ let skip_check_tt_count = match loc.kind {
+ MacroCallKind::FnLike { ast_id, expand_to: _ } => {
+ if let Some(name_ref) =
+ ast_id.to_node(db).path().and_then(|p| p.segment()).and_then(|s| s.name_ref())
+ {
+ name_ref.text() == "include"
+ } else {
+ false
+ }
+ }
+ _ => false,
+ };
+
+ if !skip_check_tt_count {
+ // Set a hard limit for the expanded tt
+ if let Err(value) = check_tt_count(&tt) {
+ return value;
+ }
}
ExpandResult { value: Arc::new(tt), err }