@@ -19,7 +19,6 @@ use hir_expand::{
19
19
use intern:: { sym, Interned } ;
20
20
use itertools:: { izip, Itertools } ;
21
21
use la_arena:: Idx ;
22
- use limit:: Limit ;
23
22
use rustc_hash:: { FxHashMap , FxHashSet } ;
24
23
use span:: { Edition , EditionedFileId , FileAstId , SyntaxContextId } ;
25
24
use syntax:: ast;
@@ -55,8 +54,8 @@ use crate::{
55
54
UnresolvedMacro , UseId , UseLoc ,
56
55
} ;
57
56
58
- static GLOB_RECURSION_LIMIT : Limit = Limit :: new ( 100 ) ;
59
- static FIXED_POINT_LIMIT : Limit = Limit :: new ( 8192 ) ;
57
+ const GLOB_RECURSION_LIMIT : usize = 100 ;
58
+ const FIXED_POINT_LIMIT : usize = 8192 ;
60
59
61
60
pub ( super ) fn collect_defs ( db : & dyn DefDatabase , def_map : DefMap , tree_id : TreeId ) -> DefMap {
62
61
let crate_graph = db. crate_graph ( ) ;
@@ -393,7 +392,7 @@ impl DefCollector<'_> {
393
392
}
394
393
395
394
i += 1 ;
396
- if FIXED_POINT_LIMIT . check ( i ) . is_err ( ) {
395
+ if i > FIXED_POINT_LIMIT {
397
396
tracing:: error!( "name resolution is stuck" ) ;
398
397
break ' resolve_attr;
399
398
}
@@ -993,7 +992,7 @@ impl DefCollector<'_> {
993
992
import : Option < ImportOrExternCrate > ,
994
993
depth : usize ,
995
994
) {
996
- if GLOB_RECURSION_LIMIT . check ( depth) . is_err ( ) {
995
+ if depth > GLOB_RECURSION_LIMIT {
997
996
// prevent stack overflows (but this shouldn't be possible)
998
997
panic ! ( "infinite recursion in glob imports!" ) ;
999
998
}
@@ -1470,8 +1469,7 @@ impl DefCollector<'_> {
1470
1469
depth : usize ,
1471
1470
container : ItemContainerId ,
1472
1471
) {
1473
- let recursion_limit = Limit :: new ( self . def_map . recursion_limit ( ) as usize ) ;
1474
- if recursion_limit. check ( depth) . is_err ( ) {
1472
+ if depth > self . def_map . recursion_limit ( ) as usize {
1475
1473
cov_mark:: hit!( macro_expansion_overflow) ;
1476
1474
tracing:: warn!( "macro expansion is too deep" ) ;
1477
1475
return ;
@@ -1499,7 +1497,6 @@ impl DefCollector<'_> {
1499
1497
1500
1498
fn finish ( mut self ) -> DefMap {
1501
1499
// Emit diagnostics for all remaining unexpanded macros.
1502
-
1503
1500
let _p = tracing:: info_span!( "DefCollector::finish" ) . entered ( ) ;
1504
1501
1505
1502
for directive in & self . unresolved_macros {
0 commit comments