-
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: add flag to turn off extractor path resolution #18813
Open
redsun82
wants to merge
4
commits into
main
Choose a base branch
from
redsun82/rust-turn-off-ra-resolution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ mod base; | |
mod generated; | ||
mod mappings; | ||
|
||
pub use base::Translator; | ||
pub use base::{ResolvePaths, Translator}; |
This file contains 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
39 changes: 39 additions & 0 deletions
39
rust/ql/test/extractor-tests/canonical_path_disabled/anonymous.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// would prefer to write `include!("../canonical_paths/anonymous.rs");` | ||
// but `include!` does not work with out-of-dir files | ||
|
||
use super::regular::Trait; | ||
|
||
fn canonicals() { | ||
struct OtherStruct; | ||
|
||
trait OtherTrait { | ||
fn g(&self); | ||
} | ||
|
||
impl OtherTrait for OtherStruct { | ||
fn g(&self) {} | ||
} | ||
|
||
impl OtherTrait for crate::regular::Struct { | ||
fn g(&self) {} | ||
} | ||
|
||
impl crate::regular::Trait for OtherStruct { | ||
fn f(&self) {} | ||
} | ||
|
||
fn nested() { | ||
struct OtherStruct; | ||
} | ||
|
||
fn usage() { | ||
let s = OtherStruct {}; | ||
s.f(); | ||
s.g(); | ||
nested(); | ||
} | ||
} | ||
|
||
fn other() { | ||
struct OtherStruct; | ||
} |
66 changes: 66 additions & 0 deletions
66
rust/ql/test/extractor-tests/canonical_path_disabled/canonical_paths.expected
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
canonicalPaths | ||
| anonymous.rs:4:1:4:26 | Use | None | None | | ||
| anonymous.rs:6:1:35:1 | fn canonicals | None | None | | ||
| anonymous.rs:7:5:7:23 | struct OtherStruct | None | None | | ||
| anonymous.rs:9:5:11:5 | trait OtherTrait | None | None | | ||
| anonymous.rs:10:9:10:20 | fn g | None | None | | ||
| anonymous.rs:13:5:15:5 | impl OtherTrait for OtherStruct { ... } | None | None | | ||
| anonymous.rs:14:9:14:22 | fn g | None | None | | ||
| anonymous.rs:17:5:19:5 | impl OtherTrait for ...::Struct { ... } | None | None | | ||
| anonymous.rs:18:9:18:22 | fn g | None | None | | ||
| anonymous.rs:21:5:23:5 | impl ...::Trait for OtherStruct { ... } | None | None | | ||
| anonymous.rs:22:9:22:22 | fn f | None | None | | ||
| anonymous.rs:25:5:27:5 | fn nested | None | None | | ||
| anonymous.rs:26:9:26:27 | struct OtherStruct | None | None | | ||
| anonymous.rs:29:5:34:5 | fn usage | None | None | | ||
| anonymous.rs:37:1:39:1 | fn other | None | None | | ||
| anonymous.rs:38:5:38:23 | struct OtherStruct | None | None | | ||
| lib.rs:1:1:1:14 | mod anonymous | None | None | | ||
| lib.rs:2:1:2:12 | mod regular | None | None | | ||
| regular.rs:4:1:5:18 | struct Struct | None | None | | ||
| regular.rs:7:1:9:1 | trait Trait | None | None | | ||
| regular.rs:8:5:8:16 | fn f | None | None | | ||
| regular.rs:11:1:13:1 | impl Trait for Struct { ... } | None | None | | ||
| regular.rs:12:5:12:18 | fn f | None | None | | ||
| regular.rs:15:1:17:1 | impl Struct { ... } | None | None | | ||
| regular.rs:16:5:16:18 | fn g | None | None | | ||
| regular.rs:19:1:21:1 | trait TraitWithBlanketImpl | None | None | | ||
| regular.rs:20:5:20:16 | fn h | None | None | | ||
| regular.rs:23:1:25:1 | impl TraitWithBlanketImpl for T { ... } | None | None | | ||
| regular.rs:24:5:24:18 | fn h | None | None | | ||
| regular.rs:27:1:27:12 | fn free | None | None | | ||
| regular.rs:29:1:35:1 | fn usage | None | None | | ||
| regular.rs:37:1:41:1 | enum MyEnum | None | None | | ||
| regular.rs:43:1:49:1 | fn enum_qualified_usage | None | None | | ||
| regular.rs:51:1:58:1 | fn enum_unqualified_usage | None | None | | ||
| regular.rs:54:5:54:18 | Use | None | None | | ||
| regular.rs:60:1:66:1 | fn enum_match | None | None | | ||
resolvedPaths | ||
| anonymous.rs:30:17:30:30 | OtherStruct {...} | None | None | | ||
| anonymous.rs:31:9:31:9 | s | None | None | | ||
| anonymous.rs:31:9:31:13 | s.f(...) | None | None | | ||
| anonymous.rs:32:9:32:9 | s | None | None | | ||
| anonymous.rs:32:9:32:13 | s.g(...) | None | None | | ||
| anonymous.rs:33:9:33:14 | nested | None | None | | ||
| regular.rs:30:13:30:21 | Struct {...} | None | None | | ||
| regular.rs:31:5:31:5 | s | None | None | | ||
| regular.rs:31:5:31:9 | s.f(...) | None | None | | ||
| regular.rs:32:5:32:5 | s | None | None | | ||
| regular.rs:32:5:32:9 | s.g(...) | None | None | | ||
| regular.rs:33:5:33:5 | s | None | None | | ||
| regular.rs:33:5:33:9 | s.h(...) | None | None | | ||
| regular.rs:34:5:34:8 | free | None | None | | ||
| regular.rs:44:9:44:26 | ...::None::<...> | None | None | | ||
| regular.rs:45:9:45:20 | ...::Some | None | None | | ||
| regular.rs:46:9:46:24 | ...::Variant1 | None | None | | ||
| regular.rs:47:9:47:24 | ...::Variant2 | None | None | | ||
| regular.rs:48:9:48:33 | ...::Variant3 {...} | None | None | | ||
| regular.rs:52:9:52:18 | None::<...> | None | None | | ||
| regular.rs:53:9:53:12 | Some | None | None | | ||
| regular.rs:55:9:55:16 | Variant1 | None | None | | ||
| regular.rs:56:9:56:16 | Variant2 | None | None | | ||
| regular.rs:57:9:57:25 | Variant3 {...} | None | None | | ||
| regular.rs:61:11:61:11 | e | None | None | | ||
| regular.rs:62:9:62:24 | ...::Variant1 | None | None | | ||
| regular.rs:63:9:63:27 | ...::Variant2(...) | None | None | | ||
| regular.rs:64:9:64:31 | ...::Variant3 {...} | None | None | |
1 change: 1 addition & 0 deletions
1
rust/ql/test/extractor-tests/canonical_path_disabled/canonical_paths.qlref
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extractor-tests/canonical_path/canonical_paths.ql | ||
1 change: 1 addition & 0 deletions
1
rust/ql/test/extractor-tests/canonical_path_disabled/options.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
skip_path_resolution: true |
66 changes: 66 additions & 0 deletions
66
rust/ql/test/extractor-tests/canonical_path_disabled/regular.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// would prefer to write `include!("../canonical_path/regular.rs"); | ||
// but `include!` does not work with out-of-dir files | ||
|
||
#[derive(Eq, PartialEq)] | ||
pub struct Struct; | ||
|
||
pub trait Trait { | ||
fn f(&self); | ||
} | ||
|
||
impl Trait for Struct { | ||
fn f(&self) {} | ||
} | ||
|
||
impl Struct { | ||
fn g(&self) {} | ||
} | ||
|
||
trait TraitWithBlanketImpl { | ||
fn h(&self); | ||
} | ||
|
||
impl<T: Eq> TraitWithBlanketImpl for T { | ||
fn h(&self) {} | ||
} | ||
|
||
fn free() {} | ||
|
||
fn usage() { | ||
let s = Struct {}; | ||
s.f(); | ||
s.g(); | ||
s.h(); | ||
free(); | ||
} | ||
|
||
enum MyEnum { | ||
Variant1, | ||
Variant2(usize), | ||
Variant3 { x: usize }, | ||
} | ||
|
||
fn enum_qualified_usage() { | ||
_ = Option::None::<()>; | ||
_ = Option::Some(0); | ||
_ = MyEnum::Variant1; | ||
_ = MyEnum::Variant2(0); | ||
_ = MyEnum::Variant3 { x: 1 }; | ||
} | ||
|
||
fn enum_unqualified_usage() { | ||
_ = None::<()>; | ||
_ = Some(0); | ||
use MyEnum::*; | ||
_ = Variant1; | ||
_ = Variant2(0); | ||
_ = Variant3 { x: 1 }; | ||
} | ||
|
||
fn enum_match(e: MyEnum) { | ||
match e { | ||
MyEnum::Variant1 => {} | ||
MyEnum::Variant2(_) => {} | ||
MyEnum::Variant3 { .. } => {} | ||
} | ||
} |
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.
Check warning
Code scanning / CodeQL
Query test without inline test expectations Warning test