mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-28 14:25:43 +00:00
Remove useless and_then
This commit is contained in:
parent
70f8e04af3
commit
9155ed3826
1 changed files with 12 additions and 13 deletions
|
@ -414,21 +414,20 @@ impl SymbolTableAnalyzer {
|
|||
st_typ: SymbolTableType,
|
||||
) -> Option<SymbolScope> {
|
||||
sub_tables.iter().find_map(|st| {
|
||||
st.symbols.get(name).and_then(|sym| {
|
||||
if sym.scope == SymbolScope::Free || sym.flags.contains(SymbolFlags::FREE_CLASS) {
|
||||
if st_typ == SymbolTableType::Class && name != "__class__" {
|
||||
None
|
||||
} else {
|
||||
Some(SymbolScope::Cell)
|
||||
}
|
||||
} else if sym.scope == SymbolScope::GlobalExplicit && self.tables.is_empty() {
|
||||
// the symbol is defined on the module level, and an inner scope declares
|
||||
// a global that points to it
|
||||
Some(SymbolScope::GlobalExplicit)
|
||||
} else {
|
||||
let sym = st.symbols.get(name)?;
|
||||
if sym.scope == SymbolScope::Free || sym.flags.contains(SymbolFlags::FREE_CLASS) {
|
||||
if st_typ == SymbolTableType::Class && name != "__class__" {
|
||||
None
|
||||
} else {
|
||||
Some(SymbolScope::Cell)
|
||||
}
|
||||
})
|
||||
} else if sym.scope == SymbolScope::GlobalExplicit && self.tables.is_empty() {
|
||||
// the symbol is defined on the module level, and an inner scope declares
|
||||
// a global that points to it
|
||||
Some(SymbolScope::GlobalExplicit)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue