diff --git a/src/gen.rs b/src/gen.rs index e382f64..9310074 100644 --- a/src/gen.rs +++ b/src/gen.rs @@ -270,7 +270,7 @@ fn gen_header( if !trait_def.supertraits.is_empty() { let supertraits = &trait_def.supertraits; - out.extend(quote! { #self_ty: #supertraits, }); + out.extend(quote! { #proxy_ty_param: #supertraits, }); } if let Some(predicates) = where_clause.map(|c| &c.predicates) { out.extend(predicates.into_token_stream()); diff --git a/tests/compile-fail/super_trait_not_implemented.stderr b/tests/compile-fail/super_trait_not_implemented.stderr index 52513b6..1b65dd5 100644 --- a/tests/compile-fail/super_trait_not_implemented.stderr +++ b/tests/compile-fail/super_trait_not_implemented.stderr @@ -1,22 +1,27 @@ -error[E0277]: the trait bound `Box: Supi` is not satisfied - --> tests/compile-fail/super_trait_not_implemented.rs:18:18 - | -18 | requires_foo(Box::new(Dog)); // shouldn't, because `Box: Supi` is not satisfied - | ------------ ^^^^^^^^^^^^^ the trait `Supi` is not implemented for `Box` - | | - | required by a bound introduced by this call - | - = help: the trait `Supi` is implemented for `Dog` -note: required for `Box` to implement `Foo` - --> tests/compile-fail/super_trait_not_implemented.rs:5:1 - | -5 | #[auto_impl(Box, &)] - | ^^^^^^^^^^^^^^^^^^^^ -6 | trait Foo: Supi {} - | ^^^ ---- unsatisfied trait bound introduced here -note: required by a bound in `requires_foo` - --> tests/compile-fail/super_trait_not_implemented.rs:14:20 - | -14 | fn requires_foo(_: T) {} - | ^^^ required by this bound in `requires_foo` - = note: this error originates in the attribute macro `auto_impl` (in Nightly builds, run with -Z macro-backtrace for more info) +error[E0277]: the trait bound `Box: Supi` is not satisfied + --> tests/compile-fail/super_trait_not_implemented.rs:5:1 + | +5 | #[auto_impl(Box, &)] + | ^^^^^^^^^^^^^^^^^^^^ the trait `Supi` is not implemented for `Box` + | + = help: the trait `Supi` is implemented for `Dog` +note: required by a bound in `Foo` + --> tests/compile-fail/super_trait_not_implemented.rs:6:12 + | +6 | trait Foo: Supi {} + | ^^^^ required by this bound in `Foo` + = note: this error originates in the attribute macro `auto_impl` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `&'a T: Supi` is not satisfied + --> tests/compile-fail/super_trait_not_implemented.rs:5:1 + | +5 | #[auto_impl(Box, &)] + | ^^^^^^^^^^^^^^^^^^^^ the trait `Supi` is not implemented for `&'a T` + | + = help: the trait `Supi` is implemented for `Dog` +note: required by a bound in `Foo` + --> tests/compile-fail/super_trait_not_implemented.rs:6:12 + | +6 | trait Foo: Supi {} + | ^^^^ required by this bound in `Foo` + = note: this error originates in the attribute macro `auto_impl` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/compile-pass/super_trait_associated_type.rs b/tests/compile-pass/super_trait_associated_type.rs new file mode 100644 index 0000000..a2f47d5 --- /dev/null +++ b/tests/compile-pass/super_trait_associated_type.rs @@ -0,0 +1,14 @@ +use auto_impl::auto_impl; + +#[auto_impl(Box, &)] +trait Supi { + type Assoc; +} + +#[auto_impl(Box, &)] +trait Foo: Supi { + fn foo(&self, x: Self::Assoc) -> String; +} + + +fn main() {} diff --git a/tests/compile-pass/super_trait_complex_for_refs.rs b/tests/compile-pass/super_trait_complex_for_refs.rs index 1be1ef6..5d3def7 100644 --- a/tests/compile-pass/super_trait_complex_for_refs.rs +++ b/tests/compile-pass/super_trait_complex_for_refs.rs @@ -1,5 +1,6 @@ use auto_impl::auto_impl; +#[auto_impl(Box, &)] trait Supi<'a, T> { fn supi(&self); } diff --git a/tests/compile-pass/super_trait_simple_for_refs.rs b/tests/compile-pass/super_trait_simple_for_refs.rs index a1a8018..18a56f9 100644 --- a/tests/compile-pass/super_trait_simple_for_refs.rs +++ b/tests/compile-pass/super_trait_simple_for_refs.rs @@ -1,5 +1,6 @@ use auto_impl::auto_impl; +#[auto_impl(Box, &)] trait Supi {} #[auto_impl(Box, &)]