mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-15 17:15:24 +00:00
Fix nightly clippy warnings
This commit is contained in:
parent
7b9e7e0443
commit
9250260e20
8 changed files with 45 additions and 48 deletions
|
@ -457,7 +457,7 @@ impl Compiler {
|
|||
NameUsage::Delete if is_forbidden_name(name) => "cannot delete",
|
||||
_ => return Ok(()),
|
||||
};
|
||||
Err(self.error(CodegenErrorType::SyntaxError(format!("{} {}", msg, name))))
|
||||
Err(self.error(CodegenErrorType::SyntaxError(format!("{msg} {name}"))))
|
||||
}
|
||||
|
||||
fn compile_name(&mut self, name: &str, usage: NameUsage) -> CompileResult<()> {
|
||||
|
|
|
@ -37,8 +37,8 @@ impl fmt::Display for CodegenErrorType {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use CodegenErrorType::*;
|
||||
match self {
|
||||
Assign(target) => write!(f, "cannot assign to {}", target),
|
||||
Delete(target) => write!(f, "cannot delete {}", target),
|
||||
Assign(target) => write!(f, "cannot assign to {target}"),
|
||||
Delete(target) => write!(f, "cannot delete {target}"),
|
||||
SyntaxError(err) => write!(f, "{}", err.as_str()),
|
||||
MultipleStarArgs => {
|
||||
write!(f, "two starred expressions in assignment")
|
||||
|
@ -59,7 +59,7 @@ impl fmt::Display for CodegenErrorType {
|
|||
"from __future__ imports must occur at the beginning of the file"
|
||||
),
|
||||
InvalidFutureFeature(feat) => {
|
||||
write!(f, "future feature {} is not defined", feat)
|
||||
write!(f, "future feature {feat} is not defined")
|
||||
}
|
||||
FunctionImportStar => {
|
||||
write!(f, "import * only allowed at module level")
|
||||
|
|
|
@ -1154,27 +1154,26 @@ impl SymbolTableBuilder {
|
|||
SymbolUsage::Global if !symbol.is_global() => {
|
||||
if flags.contains(SymbolFlags::PARAMETER) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!("name '{}' is parameter and global", name),
|
||||
error: format!("name '{name}' is parameter and global"),
|
||||
location,
|
||||
});
|
||||
}
|
||||
if flags.contains(SymbolFlags::REFERENCED) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!("name '{}' is used prior to global declaration", name),
|
||||
error: format!("name '{name}' is used prior to global declaration"),
|
||||
location,
|
||||
});
|
||||
}
|
||||
if flags.contains(SymbolFlags::ANNOTATED) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!("annotated name '{}' can't be global", name),
|
||||
error: format!("annotated name '{name}' can't be global"),
|
||||
location,
|
||||
});
|
||||
}
|
||||
if flags.contains(SymbolFlags::ASSIGNED) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!(
|
||||
"name '{}' is assigned to before global declaration",
|
||||
name
|
||||
"name '{name}' is assigned to before global declaration"
|
||||
),
|
||||
location,
|
||||
});
|
||||
|
@ -1183,27 +1182,26 @@ impl SymbolTableBuilder {
|
|||
SymbolUsage::Nonlocal => {
|
||||
if flags.contains(SymbolFlags::PARAMETER) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!("name '{}' is parameter and nonlocal", name),
|
||||
error: format!("name '{name}' is parameter and nonlocal"),
|
||||
location,
|
||||
});
|
||||
}
|
||||
if flags.contains(SymbolFlags::REFERENCED) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!("name '{}' is used prior to nonlocal declaration", name),
|
||||
error: format!("name '{name}' is used prior to nonlocal declaration"),
|
||||
location,
|
||||
});
|
||||
}
|
||||
if flags.contains(SymbolFlags::ANNOTATED) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!("annotated name '{}' can't be nonlocal", name),
|
||||
error: format!("annotated name '{name}' can't be nonlocal"),
|
||||
location,
|
||||
});
|
||||
}
|
||||
if flags.contains(SymbolFlags::ASSIGNED) {
|
||||
return Err(SymbolTableError {
|
||||
error: format!(
|
||||
"name '{}' is assigned to before nonlocal declaration",
|
||||
name
|
||||
"name '{name}' is assigned to before nonlocal declaration"
|
||||
),
|
||||
location,
|
||||
});
|
||||
|
@ -1220,7 +1218,7 @@ impl SymbolTableBuilder {
|
|||
match role {
|
||||
SymbolUsage::Nonlocal if scope_depth < 2 => {
|
||||
return Err(SymbolTableError {
|
||||
error: format!("cannot define nonlocal '{}' at top level.", name),
|
||||
error: format!("cannot define nonlocal '{name}' at top level."),
|
||||
location,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue