mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
refactor: Use while let Some
instead of calling is_empty
(#180)
This commit is contained in:
parent
08152787e1
commit
2ba767957d
1 changed files with 4 additions and 10 deletions
|
@ -1176,8 +1176,7 @@ impl<'a> Checker<'a> {
|
||||||
where
|
where
|
||||||
'b: 'a,
|
'b: 'a,
|
||||||
{
|
{
|
||||||
while !self.deferred_annotations.is_empty() {
|
while let Some((location, expression)) = self.deferred_annotations.pop() {
|
||||||
let (location, expression) = self.deferred_annotations.pop().unwrap();
|
|
||||||
if let Ok(mut expr) = parser::parse_expression(expression, path) {
|
if let Ok(mut expr) = parser::parse_expression(expression, path) {
|
||||||
relocate_expr(&mut expr, location);
|
relocate_expr(&mut expr, location);
|
||||||
allocator.push(expr);
|
allocator.push(expr);
|
||||||
|
@ -1194,9 +1193,7 @@ impl<'a> Checker<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_deferred_functions(&mut self) {
|
fn check_deferred_functions(&mut self) {
|
||||||
while !self.deferred_functions.is_empty() {
|
while let Some((stmt, scopes, parents)) = self.deferred_functions.pop() {
|
||||||
let (stmt, scopes, parents) = self.deferred_functions.pop().unwrap();
|
|
||||||
|
|
||||||
self.parent_stack = parents;
|
self.parent_stack = parents;
|
||||||
self.scope_stack = scopes;
|
self.scope_stack = scopes;
|
||||||
self.push_scope(Scope::new(ScopeKind::Function));
|
self.push_scope(Scope::new(ScopeKind::Function));
|
||||||
|
@ -1220,9 +1217,7 @@ impl<'a> Checker<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_deferred_lambdas(&mut self) {
|
fn check_deferred_lambdas(&mut self) {
|
||||||
while !self.deferred_lambdas.is_empty() {
|
while let Some((expr, scopes, parents)) = self.deferred_lambdas.pop() {
|
||||||
let (expr, scopes, parents) = self.deferred_lambdas.pop().unwrap();
|
|
||||||
|
|
||||||
self.parent_stack = parents;
|
self.parent_stack = parents;
|
||||||
self.scope_stack = scopes;
|
self.scope_stack = scopes;
|
||||||
self.push_scope(Scope::new(ScopeKind::Function));
|
self.push_scope(Scope::new(ScopeKind::Function));
|
||||||
|
@ -1240,8 +1235,7 @@ impl<'a> Checker<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_deferred_assignments(&mut self) {
|
fn check_deferred_assignments(&mut self) {
|
||||||
while !self.deferred_assignments.is_empty() {
|
while let Some(index) = self.deferred_assignments.pop() {
|
||||||
let index = self.deferred_assignments.pop().unwrap();
|
|
||||||
if self.settings.select.contains(&CheckCode::F841) {
|
if self.settings.select.contains(&CheckCode::F841) {
|
||||||
self.checks
|
self.checks
|
||||||
.extend(checks::check_unused_variables(&self.scopes[index]));
|
.extend(checks::check_unused_variables(&self.scopes[index]));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue