-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17442 from geoffw0/files
Rust: Extracted Files diagnostic query
- Loading branch information
Showing
8 changed files
with
92 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* @name Extracted files | ||
* @description Lists all files in the source code directory that were extracted. | ||
* @kind diagnostic | ||
* @id rust/diagnostics/successfully-extracted-files | ||
* @tags successfully-extracted-files | ||
*/ | ||
|
||
import rust | ||
|
||
from File f | ||
where exists(f.getRelativePath()) | ||
select f, "File successfully extracted." |
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,6 @@ | ||
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | File successfully extracted. | | ||
| error.rs:0:0:0:0 | error.rs | File successfully extracted. | | ||
| lib.rs:0:0:0:0 | lib.rs | File successfully extracted. | | ||
| main.rs:0:0:0:0 | main.rs | File successfully extracted. | | ||
| my_macro.rs:0:0:0:0 | my_macro.rs | File successfully extracted. | | ||
| my_struct.rs:0:0:0:0 | my_struct.rs | File successfully extracted. | |
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 @@ | ||
queries/diagnostics/ExtractedFiles.ql |
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,3 @@ | ||
pub fn my_func() { | ||
This is not correct Rust code. | ||
} |
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,3 @@ | ||
pub fn my_func() { | ||
compile_error!("An error!"); | ||
} |
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,18 @@ | ||
/** | ||
* total lines in this file: 18 | ||
* of which code: 7 | ||
* of which only comments: 7 | ||
* of which blank: 4 | ||
*/ | ||
|
||
mod my_struct; | ||
mod my_macro; | ||
|
||
// another comment | ||
|
||
fn main() { | ||
println!("Hello, world!"); // another comment | ||
|
||
my_struct::my_func(); | ||
my_macro::my_func(); | ||
} |
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,18 @@ | ||
/** | ||
* total lines in this file: 18 | ||
* of which code: 10 | ||
* of which only comments: 6 | ||
* of which blank: 2 | ||
*/ | ||
|
||
macro_rules! myMacro { | ||
() => { | ||
println!("Hello, world!"); | ||
}; | ||
} | ||
|
||
pub fn my_func() { | ||
if true { | ||
myMacro!(); | ||
} | ||
} |
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,30 @@ | ||
#![allow(dead_code)] | ||
/** | ||
* total lines in this file: 30 | ||
* of which code: 20 | ||
* of which only comments: 6 | ||
* of which blank: 4 | ||
*/ | ||
|
||
#[derive(Debug)] | ||
struct MyStruct { | ||
name: String, | ||
value: i32, | ||
} | ||
|
||
impl MyStruct { | ||
fn my_method(&self) { | ||
println!("Hello, world!"); | ||
} | ||
} | ||
|
||
pub fn my_func() { | ||
let _a = 1; | ||
let b = | ||
MyStruct { | ||
name: String::from("abc"), | ||
value: 123, | ||
}; | ||
|
||
b.my_method(); | ||
} |