Use Flags::intersects rather than Flags::contains (#6007)

## Summary

This is equivalent for a single flag, but I think it's more likely to be
correct when the bitflags are modified -- the primary reason being that
we sometimes define flags as the union of other flags, e.g.:

```rust
const ANNOTATION = Self::TYPING_ONLY_ANNOTATION.bits() | Self::RUNTIME_ANNOTATION.bits();
```

In this case, `flags.contains(Flag::ANNOTATION)` requires that _both_
flags in the union are set, whereas `flags.intersects(Flag::ANNOTATION)`
requires that _at least one_ flag is set.
This commit is contained in:
Charlie Marsh 2023-07-22 22:59:31 -04:00 committed by GitHub
parent 0bb175f7f6
commit 057faabcdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 31 deletions

View file

@ -163,7 +163,7 @@ impl<'a> Scope<'a> {
/// Returns `true` if this scope uses locals (e.g., `locals()`).
pub const fn uses_locals(&self) -> bool {
self.flags.contains(ScopeFlags::USES_LOCALS)
self.flags.intersects(ScopeFlags::USES_LOCALS)
}
}