Repository: auto-impl-rs/auto_impl (rust)

Issue:
const generics support
Consider the following code. It currently does not compile (on version 1.0.0).

```rs
#[auto_impl::auto_impl(&)]
trait Foo {
    fn foo<const I: i32>(&self);
}

fn main() {}
```

Using `cargo expand` I believe the macro expands to:
```rs
impl<'a, T: 'a + Foo + ?::core::marker::Sized> Foo for &'a T {
    fn foo<const I: i32>(&self) {
        T::foo(self)
    }
}
```

The `T::foo(self)` should be `T::foo::<I>(self)`

Pull request description:
Include const params when building generics
Closes #84 

We were previously missing const generics when generating proxy types, which leads to miscompilations.

Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 39f3230..077a491 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,3 +32,4 @@ proc-macro-error = "1.0.0"
 
 [dev-dependencies]
 trybuild = "1"
+rustversion = "1"
diff --git a/examples/async_await/src/main.rs b/examples/async_await/src/main.rs
index 78f9286..bae9a02 100644
--- a/examples/async_await/src/main.rs
+++ b/examples/async_await/src/main.rs
@@ -1,5 +1,5 @@
-use std::time::Duration;
 use async_std::task;
+use std::time::Duration;
 
 use async_trait::async_trait;
 use auto_impl::auto_impl;
diff --git a/src/gen.rs b/src/gen.rs
index e6c36f6..6bdba64 100644
--- a/src/gen.rs
+++ b/src/gen.rs
@@ -1,8 +1,12 @@
 use proc_macro2::{Span as Span2, TokenStream as TokenStream2};
 use proc_macro_error::{abort, emit_error};
 use quote::{ToTokens, TokenStreamExt};
-use syn::{spanned::Spanned, Attribute, FnArg, Ident, ItemTrait, Lifetime, Pat, PatIdent, ReturnType, Signature, TraitBound, TraitBoundModifier, TraitItem, TraitItemConst, TraitItemMethod, TraitItemType, Type, TypeParamBound, WherePredicate, PatType, Token};
-use syn::punctuated::Punctuated;
+use syn::{
+    punctuated::Punctuated, spanned::Spanned, Attribute, FnArg, GenericParam, Ident, ItemTrait,
+    Lifetime, Pat, PatIdent, PatType, ReturnType, Signature, Token, TraitBound, TraitBoundModifier,
+    TraitItem, TraitItemConst, TraitItemMethod, TraitItemType, Type, TypeParamBound,
+    WherePredicate,
+};
 
 use crate::{
     analyze::find_suitable_param_names,
@@ -602,7 +606,7 @@ fn gen_method_item(
                 item.sig.ident,
             );
             Err(())
-        }
+        };
     }
 
     // Determine the kind of the method, determined by the self type.
@@ -656,12 +660,21 @@ fn gen_method_item(
     // so we can wait a bit still.
     let generic_types = sig
         .generics
-        .type_params()
-        .map(|param| {
-            let name = &param.ident;
-            quote! { #name , }
+        .params
+        .iter()
+        .filter_map(|param| match param {
+            GenericParam::Type(param) => {
+                let name = &param.ident;
+                Some(quote! { #name , })
+            }
+            GenericParam::Const(param) => {
+                let name = &param.ident;
+                Some(quote! { #name , })
+            }
+            GenericParam::Lifetime(_) => None,
         })
         .collect::<TokenStream2>();
+
     let generic_types = if generic_types.is_empty() {
         generic_types
     } else {
@@ -801,7 +814,9 @@ fn check_receiver_compatible(
 /// Generates a list of comma-separated arguments used to call the function.
 /// Currently, only simple names are valid and more complex pattern will lead
 /// to an error being emitted. `self` parameters are ignored.
-fn get_arg_list<'a>(original_inputs: impl Iterator<Item = &'a FnArg>) -> (Punctuated<FnArg, Token![,]>, TokenStream2) {
+fn get_arg_list<'a>(
+    original_inputs: impl Iterator<Item = &'a FnArg>,
+) -> (Punctuated<FnArg, Token![,]>, TokenStream2) {
     let mut args = TokenStream2::new();
     let mut inputs = Punctuated::new();
 


Test patch:
diff --git a/tests/recent/compile-pass/generic_const_method.rs b/tests/recent/compile-pass/generic_const_method.rs
new file mode 100644
index 0000000..39ee139
--- /dev/null
+++ b/tests/recent/compile-pass/generic_const_method.rs
@@ -0,0 +1,10 @@
+use auto_impl::auto_impl;
+
+
+#[auto_impl(&)]
+trait Foo {
+    fn foo<const I: i32>(&self);
+}
+
+
+fn main() {}
diff --git a/tests/recent/compile-pass/generic_mix.rs b/tests/recent/compile-pass/generic_mix.rs
new file mode 100644
index 0000000..69830f5
--- /dev/null
+++ b/tests/recent/compile-pass/generic_mix.rs
@@ -0,0 +1,9 @@
+use auto_impl::auto_impl;
+
+#[auto_impl(&, &mut)]
+trait MyTrait<'a, T> {
+    fn execute<'b, U, const N: usize>(&'a self, arg1: &'b T, arg2: &'static str, arg3: U) -> Result<(), String>;
+}
+
+
+fn main() {}
diff --git a/tests/ui.rs b/tests/ui.rs
index 2258430..68c466b 100644
--- a/tests/ui.rs
+++ b/tests/ui.rs
@@ -11,3 +11,10 @@ fn ui_compile_fail() {
     let t = TestCases::new();
     t.compile_fail("tests/compile-fail/*.rs");
 }
+
+#[rustversion::since(1.51)]
+#[test]
+fn ui_recent_compile_pass() {
+    let t = TestCases::new();
+    t.pass("tests/recent/compile-pass/*.rs");
+}