Rust: exclude extraction of code excluded by cfg#18313
Merged
Conversation
92a10b8 to
a6ec51a
Compare
7804b56 to
218bc80
Compare
Contributor
There was a problem hiding this comment.
Copilot reviewed 3 out of 6 changed files in this pull request and generated 1 comment.
Files not reviewed (3)
- rust/ql/integration-tests/options/cfg/functions.ql: Language not supported
- rust/ql/integration-tests/options/features/functions.ql: Language not supported
- rust/ql/integration-tests/options/target/functions.ql: Language not supported
Comments suppressed due to low confidence (1)
rust/ast-generator/src/main.rs:527
- [nitpick] The variable name 'field' is too generic. Consider renaming it to 'node_field' for better clarity.
if field.name == "attrs" {
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
paldepind
reviewed
Jan 6, 2025
rust/extractor/src/translate/base.rs
Outdated
Comment on lines
566
to
573
| for attr in item.attrs() { | ||
| if let Some((name, tokens)) = attr.as_simple_call() { | ||
| if name == "cfg" && sema.check_cfg_attr(&tokens) == Some(false) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| false |
Contributor
There was a problem hiding this comment.
Perhaps this would be nicer with any and is_some_and?
Suggested change
| for attr in item.attrs() { | |
| if let Some((name, tokens)) = attr.as_simple_call() { | |
| if name == "cfg" && sema.check_cfg_attr(&tokens) == Some(false) { | |
| return true; | |
| } | |
| } | |
| } | |
| false | |
| item.attrs().any(|attr| { | |
| attr.as_simple_call().is_some_and(|(name, tokens)| { | |
| name == "cfg" && sema.check_cfg_attr(&tokens) == Some(false) | |
| }) | |
| }) |
paldepind
approved these changes
Jan 8, 2025
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 change skips all extraction of disabled
#[cfg]blocks. This:This requires a newer version of
rust-analyzerthan what we have onmain, reason for which this sits on top of #18295 and should be merged after that.