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

Fix cfg using non-existing feature #5

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

GuillaumeGomez
Copy link
Contributor

Fixes this warning:

warning: unexpected `cfg` condition value: `toml`
   --> rinja_derive/src/config.rs:576:11
    |
576 |     #[cfg(feature = "toml")]
    |           ^^^^^^^^^^^^^^^^
    |
    = note: expected values for `feature` are: `basic-toml`, `config`, `humansize`, `num-traits`, `serde`, `serde-json`, `urlencode`, `with-actix-web`, `with-axum`, `with-rocket`, and `with-warp`
    = help: consider adding `toml` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration

It's been a while that this was the case though. Seems like these tests were basically never run?

@Kijewski
Copy link
Collaborator

I think we should update the features to suppress implicit features like some_crate, and use dep:some_crate instead. Then it will be clearer what the actual feature names are.

@GuillaumeGomez
Copy link
Contributor Author

Good idea!

@GuillaumeGomez
Copy link
Contributor Author

Fixed it.

@@ -14,7 +14,9 @@ rust-version = "1.65"
proc-macro = true

[features]
config = ["serde", "basic-toml"]
config = ["serde", "toml"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the use of serde and basic-toml are implementation details, so the line should read config = ["dep:serde", "dep:basic-toml"], without exposing them as features.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's what I did originally but cargo was unhappy with feature = "basic-toml". Hence why I went full in.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah. I guess all usages of #[cfg(feature = "toml")], #[cfg(feature = "basic-toml")], and #[cfg(feature = "serde")] are wrong in rinja_derive, and should be #[cfg(feature = "config")] instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that makes more sense. Changing to that then!

@GuillaumeGomez
Copy link
Contributor Author

And fixed clippy too. :)

@Kijewski
Copy link
Collaborator

I love clippy. :) Those kind of bugs and shortcomings are impossible to find unless to read the whole code base repeatedly.

@Kijewski Kijewski merged commit 435ecc2 into rinja-rs:master Jun 18, 2024
16 checks passed
@GuillaumeGomez
Copy link
Contributor Author

It's not clippy but rustc in this case. But yes, it's really awesome!

@GuillaumeGomez GuillaumeGomez deleted the non-existent-feature branch June 18, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants