Merge pull request #4223 from youknowone/nightly-clippy

Fix nightly clippy warnings
This commit is contained in:
Jeong YunWon 2022-10-17 13:28:53 +09:00 committed by GitHub
commit 14e0398eb8
2 changed files with 10 additions and 22 deletions

View file

@ -342,7 +342,7 @@ impl Compiler {
self.emit(Instruction::StoreGlobal(doc)) self.emit(Instruction::StoreGlobal(doc))
} }
if self.find_ann(statements) { if Self::find_ann(statements) {
self.emit(Instruction::SetupAnnotation); self.emit(Instruction::SetupAnnotation);
} }
@ -1229,22 +1229,22 @@ impl Compiler {
} }
// Python/compile.c find_ann // Python/compile.c find_ann
fn find_ann(&self, body: &[ast::Stmt]) -> bool { fn find_ann(body: &[ast::Stmt]) -> bool {
use ast::StmtKind::*; use ast::StmtKind::*;
for statement in body { for statement in body {
let res = match &statement.node { let res = match &statement.node {
AnnAssign { .. } => true, AnnAssign { .. } => true,
For { body, orelse, .. } => self.find_ann(body) || self.find_ann(orelse), For { body, orelse, .. } => Self::find_ann(body) || Self::find_ann(orelse),
If { body, orelse, .. } => self.find_ann(body) || self.find_ann(orelse), If { body, orelse, .. } => Self::find_ann(body) || Self::find_ann(orelse),
While { body, orelse, .. } => self.find_ann(body) || self.find_ann(orelse), While { body, orelse, .. } => Self::find_ann(body) || Self::find_ann(orelse),
With { body, .. } => self.find_ann(body), With { body, .. } => Self::find_ann(body),
Try { Try {
body, body,
orelse, orelse,
finalbody, finalbody,
.. ..
} => self.find_ann(body) || self.find_ann(orelse) || self.find_ann(finalbody), } => Self::find_ann(body) || Self::find_ann(orelse) || Self::find_ann(finalbody),
_ => false, _ => false,
}; };
if res { if res {
@ -1295,7 +1295,7 @@ impl Compiler {
let doc = self.name("__doc__"); let doc = self.name("__doc__");
self.emit(Instruction::StoreLocal(doc)); self.emit(Instruction::StoreLocal(doc));
// setup annotations // setup annotations
if self.find_ann(body) { if Self::find_ann(body) {
self.emit(Instruction::SetupAnnotation); self.emit(Instruction::SetupAnnotation);
} }
self.compile_statements(body)?; self.compile_statements(body)?;

View file

@ -996,20 +996,8 @@ impl Instruction {
| SetupFinally { .. } | SetupFinally { .. }
| EnterFinally | EnterFinally
| EndFinally => 0, | EndFinally => 0,
SetupExcept { .. } => { SetupExcept { .. } => jump as i32,
if jump { SetupWith { .. } => (!jump) as i32,
1
} else {
0
}
}
SetupWith { .. } => {
if jump {
0
} else {
1
}
}
WithCleanupStart => 0, WithCleanupStart => 0,
WithCleanupFinish => -1, WithCleanupFinish => -1,
PopBlock => 0, PopBlock => 0,