about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2023-11-10 16:48:47 +0200
committerLaurențiu Nicola <lnicola@dend.ro>2023-11-10 16:53:08 +0200
commit9826717550e9059cb15372b72cb9ee97516945ad (patch)
tree031dd9781006d0afb2a41d4bb65a0f2596e294d4
parent7cca4e5816fa57eb3b8de13a3999cc44ad01da48 (diff)
downloadrust-9826717550e9059cb15372b72cb9ee97516945ad.tar.gz
rust-9826717550e9059cb15372b72cb9ee97516945ad.zip
Improve check for include macro
-rw-r--r--crates/hir-expand/src/db.rs29
1 files changed, 6 insertions, 23 deletions
diff --git a/crates/hir-expand/src/db.rs b/crates/hir-expand/src/db.rs
index 204227e3387..ff0d279d8cc 100644
--- a/crates/hir-expand/src/db.rs
+++ b/crates/hir-expand/src/db.rs
@@ -12,15 +12,11 @@ use syntax::{
 use triomphe::Arc;
 
 use crate::{
-    ast_id_map::AstIdMap,
-    builtin_attr_macro::pseudo_derive_attr_expansion,
-    builtin_fn_macro::EagerExpander,
-    fixup,
-    hygiene::HygieneFrame,
-    name::{name, AsName},
-    tt, AstId, BuiltinAttrExpander, BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerCallInfo,
-    ExpandError, ExpandResult, ExpandTo, HirFileId, HirFileIdRepr, MacroCallId, MacroCallKind,
-    MacroCallLoc, MacroDefId, MacroDefKind, MacroFile, ProcMacroExpander,
+    ast_id_map::AstIdMap, builtin_attr_macro::pseudo_derive_attr_expansion,
+    builtin_fn_macro::EagerExpander, fixup, hygiene::HygieneFrame, tt, AstId, BuiltinAttrExpander,
+    BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerCallInfo, ExpandError, ExpandResult,
+    ExpandTo, HirFileId, HirFileIdRepr, MacroCallId, MacroCallKind, MacroCallLoc, MacroDefId,
+    MacroDefKind, MacroFile, ProcMacroExpander,
 };
 
 /// Total limit on the number of tokens produced by any macro invocation.
@@ -619,20 +615,7 @@ fn macro_expand(db: &dyn ExpandDatabase, id: MacroCallId) -> ExpandResult<Arc<tt
     }
 
     // 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.as_name() == name!(include)
-            } else {
-                false
-            }
-        }
-        _ => false,
-    };
-
-    if !skip_check_tt_count {
+    if !loc.def.is_include() {
         // Set a hard limit for the expanded tt
         if let Err(value) = check_tt_count(&tt) {
             return value;