Re-use is_magic where possible (#6945)

## Summary

Use `is_magic` where possible

## Test Plan

Unit tests
This commit is contained in:
Jelle van der Waa 2023-08-28 17:35:34 +02:00 committed by GitHub
parent ec575188c4
commit af61abc747
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -121,7 +121,7 @@ pub fn is_test(name: &str) -> bool {
/// Returns `true` if a module name indicates public visibility.
fn is_public_module(module_name: &str) -> bool {
!module_name.starts_with('_') || (module_name.starts_with("__") && module_name.ends_with("__"))
!module_name.starts_with('_') || is_magic(module_name)
}
/// Returns `true` if a module name indicates private visibility.
@ -201,7 +201,7 @@ pub(crate) fn method_visibility(function: &ast::StmtFunctionDef) -> Visibility {
}
// Is this a magic method?
if function.name.starts_with("__") && function.name.ends_with("__") {
if is_magic(&function.name) {
return Visibility::Public;
}