Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union doesn't support generics in the last version #799

Open
vpikulik opened this issue Apr 12, 2024 · 1 comment
Open

Union doesn't support generics in the last version #799

vpikulik opened this issue Apr 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@vpikulik
Copy link

Expected Behavior

Check this example master...vpikulik:union_fail_example
It compiled in previous versions

Actual Behavior

$ -> cargo check
    Checking example-openapi-union v0.1.0 (/_____/poem/examples/openapi/union)
error[E0401]: can't use generic parameters from outer item
  --> openapi/union/src/main.rs:18:9
   |
17 | enum MyObj<T: Type + ParseFromJSON + ToJSON> {
   |            - type parameter from outer item
18 |     A(A<T>),
   |         ^ use of generic parameter from outer item

For more information about this error, try `rustc --explain E0401`.
error: could not compile `example-openapi-union` (bin "example-openapi-union") due to 1 previous error

Steps to Reproduce the Problem

  1. switch to the branch https://github.com/vpikulik/poem/tree/union_fail_example
  2. cd poem/examples/openapi/union
  3. cargo check

Specifications

  • Version: rustc 1.77.2
  • Platform:
  • Subsystem:

The reason of the problem

cargo expand generates next code:

                    const _: fn() = || {
                        fn assert_impl_all<
                            T: ?Sized + poem_openapi::types::IsObjectType,
                        >() {}
                        assert_impl_all::<A<T>>();
                    };

I think crate static_assertions should be replaced.

@vpikulik vpikulik added the bug Something isn't working label Apr 12, 2024
@wpikulik
Copy link

It looks like the issue was introduced in this commit 869d7c0

The issue #800 also caused by this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants