LoopInfo::has_loops returns true when there are no loops
- Lingua principale
- Rust
- Stelle
- 115
- Fork
- 84
- Merge medio
- 1g 8h
- PR unite (30g)
- 15
Descrizione
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?
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.