Skip to content

Commit f1d281f

Browse files
committed
Rust: Add test cases for diagnostics.
1 parent a933f0d commit f1d281f

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed
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: MyStruct =
24+
MyStruct {
25+
name: String::from("abc"),
26+
value: 123,
27+
};
28+
29+
b.my_method();
30+
}

0 commit comments

Comments
 (0)