Skip to content

Commit e129914

Browse files
authored
Merge pull request github#17442 from geoffw0/files
Rust: Extracted Files diagnostic query
2 parents 40c5f10 + 587ebbf commit e129914

File tree

8 files changed

+92
-0
lines changed

8 files changed

+92
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @name Extracted files
3+
* @description Lists all files in the source code directory that were extracted.
4+
* @kind diagnostic
5+
* @id rust/diagnostics/successfully-extracted-files
6+
* @tags successfully-extracted-files
7+
*/
8+
9+
import rust
10+
11+
from File f
12+
where exists(f.getRelativePath())
13+
select f, "File successfully extracted."
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | File successfully extracted. |
2+
| error.rs:0:0:0:0 | error.rs | File successfully extracted. |
3+
| lib.rs:0:0:0:0 | lib.rs | File successfully extracted. |
4+
| main.rs:0:0:0:0 | main.rs | File successfully extracted. |
5+
| my_macro.rs:0:0:0:0 | my_macro.rs | File successfully extracted. |
6+
| my_struct.rs:0:0:0:0 | my_struct.rs | File successfully extracted. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
queries/diagnostics/ExtractedFiles.ql
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn my_func() {
2+
This is not correct Rust code.
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn my_func() {
2+
compile_error!("An error!");
3+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* total lines in this file: 18
3+
* of which code: 7
4+
* of which only comments: 7
5+
* of which blank: 4
6+
*/
7+
8+
mod my_struct;
9+
mod my_macro;
10+
11+
// another comment
12+
13+
fn main() {
14+
println!("Hello, world!"); // another comment
15+
16+
my_struct::my_func();
17+
my_macro::my_func();
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* total lines in this file: 18
3+
* of which code: 10
4+
* of which only comments: 6
5+
* of which blank: 2
6+
*/
7+
8+
macro_rules! myMacro {
9+
() => {
10+
println!("Hello, world!");
11+
};
12+
}
13+
14+
pub fn my_func() {
15+
if true {
16+
myMacro!();
17+
}
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![allow(dead_code)]
2+
/**
3+
* total lines in this file: 30
4+
* of which code: 20
5+
* of which only comments: 6
6+
* of which blank: 4
7+
*/
8+
9+
#[derive(Debug)]
10+
struct MyStruct {
11+
name: String,
12+
value: i32,
13+
}
14+
15+
impl MyStruct {
16+
fn my_method(&self) {
17+
println!("Hello, world!");
18+
}
19+
}
20+
21+
pub fn my_func() {
22+
let _a = 1;
23+
let b =
24+
MyStruct {
25+
name: String::from("abc"),
26+
value: 123,
27+
};
28+
29+
b.my_method();
30+
}

0 commit comments

Comments
 (0)