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

Events Require Use of Other Feature Flags not marked as Dependent #514

Open
nvim-ftw opened this issue Mar 4, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@nvim-ftw
Copy link

nvim-ftw commented Mar 4, 2024

Describe the bug

When compiling with the feature flag Events with minimal other feature flags and no default features, there is a compilation error:

error[E0432]: unresolved import `chrono`
 --> /home/*****/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.31.0/src/resources/webhook_e
vents.rs:3:5
  |
3 | use chrono::Utc;
  |     ^^^^^^ use of undeclared crate or module `chrono`

error[E0412]: cannot find type `AccountCapabilities` in this scope
   --> /home/*****/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.31.0/src/resources/webhook
_events.rs:428:25
    |
428 |     AccountCapabilities(AccountCapabilities),
    |                         ^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::AccountCapabilities`; try using the variant's enum
    |
428 |     AccountCapabilities(crate::EventObject),
    |                         ~~~~~~~~~~~~~~~~~~

Some errors have detailed explanations: E0412, E0432.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `async-stripe` (lib) due to 2 previous errors

It seems that the current architecture of the Event struct mandates the inclusion of ALL the feature-walled APIs. This is unfortunate because I only need a few of the features and Rust-Analyzer usually takes ages to index stripe. I understand that this would be a very difficult (maybe impossible) issue to tackle with a general solution. In the meantime, it would be good to change the feature in Cargo.toml to also include however many other features it needs (or alternatively full).

To Reproduce

  1. Add async-stripe to Cargo.toml as follows:
    async-stripe = { version = "0.31.0", default-features = false, features = ["runtime-blocking-rustls", "events"] }
  2. Compile and see the error. The error will likely differ from the one I provided because that was compiled with the checkout feature as well.

Expected behavior

The Events feature flag includes any other features required to compile. Otherwise, it is clearly documented that this is not the case.

Code snippets

No response

OS

NixOS

Rust version

1.78.0-nightly

Library version

async-stripe 0.34.1

API version

2023-10-16

Additional context

Error produced via reproduction steps:

rust/stripe_parse_test on  master [!?] is 📦 v0.1.0 via 🦀 v1.76.0 via ❄  impure (nix-shell) took 3m16s
❯ cargo run
   Compiling async-stripe v0.34.1
error[E0432]: unresolved import `chrono`
 --> /home/patrick/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.34.1/src/resources/webhook_e
  |
3 | use chrono::Utc;
  |     ^^^^^^ use of undeclared crate or module `chrono`

error[E0412]: cannot find type `AccountCapabilities` in this scope
   --> /home/*****/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.34.1/src/resources/webhook
    |
428 |     AccountCapabilities(AccountCapabilities),
    |                         ^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::AccountCapabilities`; try using the variant's enum
    |
428 |     AccountCapabilities(crate::EventObject),
    |                         ~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `BillingPortalConfiguration` in this scope
   --> /home/*****/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.34.1/src/resources/webhook_events.rs:436:32
    |
436 |     BillingPortalConfiguration(BillingPortalConfiguration),
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::BillingPortalConfiguration`; try using the variant's enum
    |
436 |     BillingPortalConfiguration(crate::EventObject),
    |                                ~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `PaymentLink` in this scope
   --> /home/*****/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.34.1/src/resources/webhook_events.rs:461:17
    |
461 |     PaymentLink(PaymentLink),
    |                 ^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::PaymentLink`; try using the variant's enum
    |
461 |     PaymentLink(crate::EventObject),
    |                 ~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `PromotionCode` in this scope
   --> /home/*****/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.34.1/src/resources/webhook_events.rs:468:19
    |
468 |     PromotionCode(PromotionCode),
    |                   ^^^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::PromotionCode`; try using the variant's enum
    |
468 |     PromotionCode(crate::EventObject),
    |                   ~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `Quote` in this scope
   --> /home/*****/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.34.1/src/resources/webhook_events.rs:469:11
    |
469 |     Quote(Quote),
    |           ^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::Quote` and 1 other; try using the variant's enum
    |
469 |     Quote(crate::EventObject),
    |           ~~~~~~~~~~~~~~~~~~
469 |     Quote(serde_json::ser::CharEscape),
    |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~

Some errors have detailed explanations: E0412, E0432.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `async-stripe` (lib) due to 6 previous errors
@nvim-ftw nvim-ftw added the bug Something isn't working label Mar 4, 2024
@nvim-ftw
Copy link
Author

nvim-ftw commented Mar 6, 2024

I'd like to tackle this with proc macros, but I don't have the experience (or really, the time) to do so right now. I image it would be feasible but require some changes to the code or some metadata provided. Otherwise, the macro may have to search through the entire project to find the feature flags that the elements are behind. I'm still not completely sure how to do this, but I'll look into it and consider a PR if I get somewhere.

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

1 participant