LoopInfo::has_loops returns true when there are no loops
- Linguagem predominante
- Rust
- Estrelas
- 115
- Forks
- 84
- Merge médio
- 1d 8h
- PRs com merge (30d)
- 15
Descrição
In the file hir/src/ir/loops.rs, the function LoopInfo::has_loops
```rust
impl LoopInfo {
/// Returns true if the op this info was derived from contains any loops
pub fn has_loops(&self) -> bool {
!self.per_region.is_empty() && !self.per_region.iter().any(|info| !info.forest.is_empty())
}
}
```
(currently: !self.per_region.is_empty() && !self.per_region.iter().any(|info| !info.forest.is_empty())) returns true when all regions of LoopForest are empty (i.e., there are no loops). This contradicts the doc comment for the method (“Returns true if the op this info was derived from contains any loops”), as well as how the presence of loops is determined in region_has_loops (!info.forest.is_empty()) and the semantics of LoopForest::is_empty() (“no loops”).
Correct: self.per_region.iter().any(|info| !info.forest.is_empty()). This way, the method returns true if there are loops in at least one region; on an empty per_region, .any(...) will return false, which is correct. This aligns the behavior with the documentation and with the logic of region_has_loops.
If you find it useful and worth, could you assing me to solve this if you dont mind?
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.