Implement iter(), len() and is_empty() for all display-literal AST nodes (#12807)

This commit is contained in:
Alex Waygood 2024-08-12 11:39:28 +01:00 committed by GitHub
parent a99a45868c
commit aa0db338d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 304 additions and 240 deletions

View file

@ -1432,9 +1432,7 @@ impl<'a> SemanticModel<'a> {
/// variable to be "used" if it's shadowed by another variable with usages.
pub fn is_unused(&self, expr: &Expr) -> bool {
match expr {
Expr::Tuple(ast::ExprTuple { elts, .. }) => {
elts.iter().all(|expr| self.is_unused(expr))
}
Expr::Tuple(tuple) => tuple.iter().all(|expr| self.is_unused(expr)),
Expr::Name(ast::ExprName { id, .. }) => {
// Treat a variable as used if it has any usages, _or_ it's shadowed by another variable
// with usages.