mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 05:35:22 +00:00
Fix nightly clippy warnings
This commit is contained in:
parent
15e2ac3fd7
commit
621f58407a
2 changed files with 10 additions and 22 deletions
|
@ -342,7 +342,7 @@ impl Compiler {
|
|||
self.emit(Instruction::StoreGlobal(doc))
|
||||
}
|
||||
|
||||
if self.find_ann(statements) {
|
||||
if Self::find_ann(statements) {
|
||||
self.emit(Instruction::SetupAnnotation);
|
||||
}
|
||||
|
||||
|
@ -1229,22 +1229,22 @@ impl Compiler {
|
|||
}
|
||||
|
||||
// Python/compile.c find_ann
|
||||
fn find_ann(&self, body: &[ast::Stmt]) -> bool {
|
||||
fn find_ann(body: &[ast::Stmt]) -> bool {
|
||||
use ast::StmtKind::*;
|
||||
|
||||
for statement in body {
|
||||
let res = match &statement.node {
|
||||
AnnAssign { .. } => true,
|
||||
For { 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),
|
||||
With { body, .. } => self.find_ann(body),
|
||||
For { 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),
|
||||
With { body, .. } => Self::find_ann(body),
|
||||
Try {
|
||||
body,
|
||||
orelse,
|
||||
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,
|
||||
};
|
||||
if res {
|
||||
|
@ -1295,7 +1295,7 @@ impl Compiler {
|
|||
let doc = self.name("__doc__");
|
||||
self.emit(Instruction::StoreLocal(doc));
|
||||
// setup annotations
|
||||
if self.find_ann(body) {
|
||||
if Self::find_ann(body) {
|
||||
self.emit(Instruction::SetupAnnotation);
|
||||
}
|
||||
self.compile_statements(body)?;
|
||||
|
|
|
@ -996,20 +996,8 @@ impl Instruction {
|
|||
| SetupFinally { .. }
|
||||
| EnterFinally
|
||||
| EndFinally => 0,
|
||||
SetupExcept { .. } => {
|
||||
if jump {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
SetupWith { .. } => {
|
||||
if jump {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
SetupExcept { .. } => jump as i32,
|
||||
SetupWith { .. } => (!jump) as i32,
|
||||
WithCleanupStart => 0,
|
||||
WithCleanupFinish => -1,
|
||||
PopBlock => 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue