File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
src/tools/rust-analyzer/crates/rust-analyzer/src Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2531,13 +2531,22 @@ macro_rules! _impl_for_config_data {
25312531 #[ allow( non_snake_case) ]
25322532 $vis fn $field( & self , source_root: Option <SourceRootId >) -> & $ty {
25332533 let mut par: Option <SourceRootId > = source_root;
2534+ let mut traversals = 0 ;
25342535 while let Some ( source_root_id) = par {
25352536 par = self . source_root_parent_map. get( & source_root_id) . copied( ) ;
25362537 if let Some ( ( config, _) ) = self . ratoml_files. get( & source_root_id) {
25372538 if let Some ( value) = config. $field. as_ref( ) {
25382539 return value;
25392540 }
25402541 }
2542+ // Prevent infinite loops caused by cycles by giving up when it's
2543+ // clear that we must have either visited all source roots or
2544+ // encountered a cycle.
2545+ traversals += 1 ;
2546+ if traversals >= self . source_root_parent_map. len( ) {
2547+ // i.e. no source root contains the config we're looking for
2548+ break ;
2549+ }
25412550 }
25422551
25432552 if let Some ( ( root_path_ratoml, _) ) = self . root_ratoml. as_ref( ) {
You can’t perform that action at this time.
0 commit comments