Remove suite body tracking from SemanticModel (#5848)

## Summary

The `SemanticModel` currently stores the "body" of a given `Suite`,
along with the current statement index. This is used to support "next
sibling" queries, but we only use this in exactly one place -- the rule
that simplifies constructs like this to `any` or `all`:

```python
for x in y:
    if x == 0:
        return True
return False
```

Instead of tracking the state, we can just do a (slightly more
expensive) traversal, by finding the node within its parent and
returning the next node in the body.

Note that we'll only have to do this extremely rarely -- namely, for
functions that contain something like:

```python
for x in y:
    if x == 0:
        return True
```
This commit is contained in:
Charlie Marsh 2023-07-18 18:58:31 -04:00 committed by GitHub
parent a93254f026
commit 2d505e2b04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 340 additions and 250 deletions

View file

@ -15,6 +15,7 @@ pub mod statement_visitor;
pub mod stmt_if;
pub mod str;
pub mod token_kind;
pub mod traversal;
pub mod types;
pub mod typing;
pub mod visitor;