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

models/krate: Improve feature validation #7537

Merged
merged 4 commits into from
Nov 16, 2023

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Nov 15, 2023

As promised in #7500 (review), I have a few suggestions on how the feature validation code can be improved :)

Compared to the output of `assert!()` (`true != false`), these give a bit more context on the actual and expected values.
`valid` is a property name, which suggests that the fn returns a `bool`. If the fn returns a `Result` it's better to name the function like an action, e.g. `validate`.
The `models` module should ideally not know anything about the HTTP API layer and the `cargo_err()` fn.
@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Nov 15, 2023
Copy link
Member

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks!

)]
Char(char, String),
#[error(transparent)]
DependencyName(#[from] InvalidDependencyName),
Copy link
Member

Choose a reason for hiding this comment

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

I'm uncertain about placing it here, as it is also used in validate_dependency. It's not intended for validating the feature name. But I can help to improve it in my next PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

InvalidDependencyName can also be used directly :)

Copy link
Member

Choose a reason for hiding this comment

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

Oh. Got it. It's nice. Thanks!

@Rustin170506 Rustin170506 merged commit fc5dbcf into rust-lang:main Nov 16, 2023
6 checks passed
@Turbo87 Turbo87 deleted the feature-validation branch November 16, 2023 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants