@@ -19,7 +19,6 @@ use hir_expand::{
1919use intern:: { sym, Interned } ;
2020use itertools:: { izip, Itertools } ;
2121use la_arena:: Idx ;
22- use limit:: Limit ;
2322use rustc_hash:: { FxHashMap , FxHashSet } ;
2423use span:: { Edition , EditionedFileId , FileAstId , SyntaxContextId } ;
2524use syntax:: ast;
@@ -55,8 +54,8 @@ use crate::{
5554 UnresolvedMacro , UseId , UseLoc ,
5655} ;
5756
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 ;
6059
6160pub ( super ) fn collect_defs ( db : & dyn DefDatabase , def_map : DefMap , tree_id : TreeId ) -> DefMap {
6261 let crate_graph = db. crate_graph ( ) ;
@@ -393,7 +392,7 @@ impl DefCollector<'_> {
393392 }
394393
395394 i += 1 ;
396- if FIXED_POINT_LIMIT . check ( i ) . is_err ( ) {
395+ if i > FIXED_POINT_LIMIT {
397396 tracing:: error!( "name resolution is stuck" ) ;
398397 break ' resolve_attr;
399398 }
@@ -993,7 +992,7 @@ impl DefCollector<'_> {
993992 import : Option < ImportOrExternCrate > ,
994993 depth : usize ,
995994 ) {
996- if GLOB_RECURSION_LIMIT . check ( depth) . is_err ( ) {
995+ if depth > GLOB_RECURSION_LIMIT {
997996 // prevent stack overflows (but this shouldn't be possible)
998997 panic ! ( "infinite recursion in glob imports!" ) ;
999998 }
@@ -1470,8 +1469,7 @@ impl DefCollector<'_> {
14701469 depth : usize ,
14711470 container : ItemContainerId ,
14721471 ) {
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 {
14751473 cov_mark:: hit!( macro_expansion_overflow) ;
14761474 tracing:: warn!( "macro expansion is too deep" ) ;
14771475 return ;
@@ -1499,7 +1497,6 @@ impl DefCollector<'_> {
14991497
15001498 fn finish ( mut self ) -> DefMap {
15011499 // Emit diagnostics for all remaining unexpanded macros.
1502-
15031500 let _p = tracing:: info_span!( "DefCollector::finish" ) . entered ( ) ;
15041501
15051502 for directive in & self . unresolved_macros {
0 commit comments