Skip to content

Commit

Permalink
clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercerenies committed Mar 4, 2023
1 parent 508bba4 commit 70b0ad3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions godot-codegen/src/class_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ fn make_virtual_methods_trait(
let virtual_methods = locate_all_virtual_methods(class, all_bases, ctx);
// TODO (HACK) Have to clone virtual_methods here to avoid a
// double borrow on ctx. Can we avoid it?
#[allow(clippy::needless_collect)]
let virtual_methods: Vec<_> = virtual_methods.into_iter().cloned().collect();

let virtual_method_fns: Vec<_> = virtual_methods
Expand All @@ -931,6 +932,7 @@ fn make_virtual_methods_trait(

quote! {
#[allow(unused_variables)]
#[allow(clippy::unimplemented)]
pub trait #trait_name: crate::private::You_forgot_the_attribute__godot_api + crate::obj::GodotClass {
#( #virtual_method_fns )*
}
Expand Down Expand Up @@ -983,15 +985,15 @@ fn locate_all_virtual_methods<'a>(
// Get virtuals defined on the current class.
all_virtuals.extend(
get_methods_in_class(class)
.into_iter()
.iter()
.filter(|meth| meth.is_virtual),
);
// Add virtuals from superclasses.
for base in all_bases {
if let Some(superclass) = ctx.get_engine_class(base) {
all_virtuals.extend(
get_methods_in_class(superclass)
.into_iter()
.iter()
.filter(|meth| meth.is_virtual),
);
}
Expand All @@ -1010,7 +1012,7 @@ fn virtual_method_name(class_method: &ClassMethod) -> String {
// Matching the C++ convention, we remove the leading underscore
// from virtual method names.
let mut method_name = class_method.name.clone();
if method_name.starts_with("_") {
if method_name.starts_with('_') {
method_name.remove(0);
}

Expand Down
2 changes: 1 addition & 1 deletion godot-codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'a> Context<'a> {
}

pub fn get_engine_class(&self, class_name: &TyName) -> Option<&Class> {
self.engine_classes.get(class_name).map(|x| *x)
self.engine_classes.get(class_name).copied()
}

// pub fn is_engine_class(&self, class_name: &str) -> bool {
Expand Down

0 comments on commit 70b0ad3

Please sign in to comment.