mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-14 16:45:25 +00:00
Apply let-else statements
This commit is contained in:
parent
54af02c20c
commit
e081f1041e
2 changed files with 3 additions and 9 deletions
|
@ -1412,9 +1412,7 @@ impl Compiler {
|
||||||
) -> CompileResult<()> {
|
) -> CompileResult<()> {
|
||||||
let with_location = self.current_source_location;
|
let with_location = self.current_source_location;
|
||||||
|
|
||||||
let (item, items) = if let Some(parts) = items.split_first() {
|
let Some((item, items)) = items.split_first() else {
|
||||||
parts
|
|
||||||
} else {
|
|
||||||
return Err(self.error(CodegenErrorType::EmptyWithItems));
|
return Err(self.error(CodegenErrorType::EmptyWithItems));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_lalrpop(source: &str, target: &str) -> Option<String> {
|
fn requires_lalrpop(source: &str, target: &str) -> Option<String> {
|
||||||
let target = if let Ok(target) = File::open(target) {
|
let Ok(target) = File::open(target) else {
|
||||||
target
|
|
||||||
} else {
|
|
||||||
return Some("python.rs doesn't exist. regenerate.".to_owned());
|
return Some("python.rs doesn't exist. regenerate.".to_owned());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,9 +69,7 @@ fn requires_lalrpop(source: &str, target: &str) -> Option<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_lalrpop(source: &str, target: &str) -> anyhow::Result<()> {
|
fn try_lalrpop(source: &str, target: &str) -> anyhow::Result<()> {
|
||||||
let _message = if let Some(msg) = requires_lalrpop(source, target) {
|
let Some(_message) = requires_lalrpop(source, target) else {
|
||||||
msg
|
|
||||||
} else {
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue