diff --git a/src/ast/checks.rs b/src/ast/checks.rs index d57622c5bd..503a6477f0 100644 --- a/src/ast/checks.rs +++ b/src/ast/checks.rs @@ -93,10 +93,11 @@ pub fn check_do_not_assign_lambda(value: &Expr, location: Location) -> Option bool { +fn is_ambiguous_name(name: &str) -> bool { name == "l" || name == "I" || name == "O" } +/// Check AmbiguousVariableName compliance. pub fn check_ambiguous_variable_name(name: &str, location: Location) -> Option { if is_ambiguous_name(name) { Some(Check::new( diff --git a/src/check_ast.rs b/src/check_ast.rs index 7e821b2d36..d9b0a221d0 100644 --- a/src/check_ast.rs +++ b/src/check_ast.rs @@ -965,11 +965,10 @@ impl<'a> Checker<'a> { } } - if self.settings.select.contains(&CheckCode::E741) && checks::is_ambiguous_name(id) { - self.checks.push(Check::new( - CheckKind::AmbiguousVariableName(id.to_string()), - expr.location, - )); + if self.settings.select.contains(&CheckCode::E741) { + if let Some(check) = checks::check_ambiguous_variable_name(id, expr.location) { + self.checks.push(check); + } } // TODO(charlie): Handle alternate binding types (like `Annotation`).