-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: use all features by default #19551
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
default
must 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_features
shadows thecargo_features
field and could be confusing; consider renaming it tocompute_cargo_features
.
fn cargo_features(&self) -> CargoFeatures {
rust/ql/integration-tests/options/features/test_features_option.py
Outdated
Show resolved
Hide resolved
@@ -126,6 +126,23 @@ impl Config { | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a doc comment for cargo_features()
to explain its behavior, particularly how default features and the deprecated '*' wildcard are handled.
/// 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. |
Copilot uses AI. Check for mistakes.
There was a problem hiding this 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. One typo that needs fixing, but otherwise OK.
Co-authored-by: Copilot <[email protected]>
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
default
will 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.