Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Enables all Cargo features by default in the extractor and lets users restrict features via the cargo_features option, with tests and docs updated accordingly.
- Introduces a
cargo_features()helper to centralize default/all/selected feature logic and uses it into_cargo_config. - Expands integration tests to cover combinations of
default, explicit features, and crates with non-empty default lists. - Updates extractor option documentation to reflect that all features are enabled by default and
defaultmust be explicitly specified to limit to default features.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| rust/ql/integration-tests/options/features/test_features_option.py | Adds new test cases and marks to cover default-feature scenarios and crates with defaults |
| rust/extractor/src/config.rs | Adds cargo_features() helper and replaces inline logic in to_cargo_config |
| rust/codeql-extractor.yml | Updates cargo_features option description to match new default behavior |
Comments suppressed due to low confidence (1)
rust/extractor/src/config.rs:129
- [nitpick] Method name
cargo_featuresshadows thecargo_featuresfield and could be confusing; consider renaming it tocompute_cargo_features.
fn cargo_features(&self) -> CargoFeatures {
| @@ -126,6 +126,23 @@ impl Config { | |||
| } | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
Add a doc comment for cargo_features() to explain its behavior, particularly how default features and the deprecated '*' wildcard are handled.
Suggested change
| /// Determines the Cargo features to be used based on the configuration. | |
| /// | |
| /// - If the `cargo_features` list is empty or contains the deprecated `'*'` wildcard, | |
| /// all features are enabled (`CargoFeatures::All`). | |
| /// - Otherwise, a subset of features is selected (`CargoFeatures::Selected`): | |
| /// - The `features` list excludes the `default` feature. | |
| /// - The `no_default_features` flag is set to `true` if the `default` feature is not present | |
| /// in the `cargo_features` list. | |
| /// | |
| /// # Note | |
| /// The `'*'` wildcard is deprecated but retained for backward compatibility. |
aibaars
reviewed
May 26, 2025
Contributor
aibaars
left a comment
There was a problem hiding this comment.
Looks good to me. One typo that needs fixing, but otherwise OK.
aibaars
approved these changes
May 29, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
123f5ef to
55791a6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes rust analysis turn on all features by default. A more restricted set of features can be specified via the cargo_features extractor option. In particular setting it to
defaultwill use default features instead (no features if no default is set for a crate).Notice that this implementation currently does not allow to turn off all features for crates that have a non-empty
default. It's to be discussed if we want to allow that, but we could use a special value like-or!for that.