-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rust: exclude extraction of code excluded by cfg
#18313
Rust: exclude extraction of code excluded by cfg
#18313
Conversation
92a10b8
to
a6ec51a
Compare
7804b56
to
218bc80
Compare
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.
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
rust/extractor/src/translate/base.rs
Outdated
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 |
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.
Perhaps this would be nicer with any
and is_some_and
?
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) | |
}) | |
}) |
This change skips all extraction of disabled
#[cfg]
blocks. This:This requires a newer version of
rust-analyzer
than what we have onmain
, reason for which this sits on top of #18295 and should be merged after that.