Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 64b9042

Browse files
authored
Merge pull request #49 from killercup/add/const-static-lifetime
Add const static lifetime test
2 parents f212450 + 446451a commit 64b9042

11 files changed

+245
-233
lines changed

tests/fixtures/E0178.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,13 @@
5858
"rendered": null
5959
}
6060
],
61-
"rendered": "error[E0178]: expected a path on the left-hand side of `+`, not `&'a Foo`\n --> ./tests/fixtures/E0178.rs:6:8\n |\n6 | w: &'a Foo + Send,\n | ^^^^^^^^^^^^^^ help: try adding parentheses: `&'a (Foo + Send)`\n\n"
61+
"rendered": "error[E0178]: expected a path on the left-hand side of `+`, not `&'a Foo`\n --> ./tests/fixtures/E0178.rs:6:8\n |\n6 | w: &'a Foo + Send,\n | ^^^^^^^^^^^^^^ help: try adding parentheses: `&'a (Foo + Send)`\n\nIf you want more information on this error, try using \"rustc --explain E0178\"\n"
62+
}
63+
{
64+
"message": "aborting due to previous error",
65+
"code": null,
66+
"level": "error",
67+
"spans": [],
68+
"children": [],
69+
"rendered": "error: aborting due to previous error\n\n"
6270
}

tests/fixtures/closure-immutable-outer-variable.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,13 @@
5858
"rendered": null
5959
}
6060
],
61-
"rendered": "error[E0594]: cannot assign to captured outer variable in an `FnMut` closure\n --> ./tests/fixtures/closure-immutable-outer-variable.rs:19:26\n |\n18 | let y = true;\n | - help: consider making `y` mutable: `mut y`\n19 | foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable\n | ^^^^^^^^^\n\n"
61+
"rendered": "error[E0594]: cannot assign to captured outer variable in an `FnMut` closure\n --> ./tests/fixtures/closure-immutable-outer-variable.rs:19:26\n |\n18 | let y = true;\n | - help: consider making `y` mutable: `mut y`\n19 | foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable\n | ^^^^^^^^^\n\nIf you want more information on this error, try using \"rustc --explain E0594\"\n"
62+
}
63+
{
64+
"message": "aborting due to previous error",
65+
"code": null,
66+
"level": "error",
67+
"spans": [],
68+
"children": [],
69+
"rendered": "error: aborting due to previous error\n\n"
6270
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const LOREM: &str = "ipsum";
2+
3+
fn main() {}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"message": "Constants have by default a `'static` lifetime",
3+
"code": {
4+
"code": "const_static_lifetime",
5+
"explanation": null
6+
},
7+
"level": "warning",
8+
"spans": [
9+
{
10+
"file_name": "./tests/fixtures/const_static_lifetime.rs",
11+
"byte_start": 14,
12+
"byte_end": 21,
13+
"line_start": 1,
14+
"line_end": 1,
15+
"column_start": 15,
16+
"column_end": 22,
17+
"is_primary": true,
18+
"text": [
19+
{
20+
"text": "const LOREM: &'static str = \"ipsum\";",
21+
"highlight_start": 15,
22+
"highlight_end": 22
23+
}
24+
],
25+
"label": null,
26+
"suggested_replacement": null,
27+
"expansion": null
28+
}
29+
],
30+
"children": [
31+
{
32+
"message": "#[warn(const_static_lifetime)] on by default",
33+
"code": null,
34+
"level": "note",
35+
"spans": [],
36+
"children": [],
37+
"rendered": null
38+
},
39+
{
40+
"message": "consider removing `'static`",
41+
"code": null,
42+
"level": "help",
43+
"spans": [
44+
{
45+
"file_name": "./tests/fixtures/const_static_lifetime.rs",
46+
"byte_start": 13,
47+
"byte_end": 25,
48+
"line_start": 1,
49+
"line_end": 1,
50+
"column_start": 14,
51+
"column_end": 26,
52+
"is_primary": true,
53+
"text": [
54+
{
55+
"text": "const LOREM: &'static str = \"ipsum\";",
56+
"highlight_start": 14,
57+
"highlight_end": 26
58+
}
59+
],
60+
"label": null,
61+
"suggested_replacement": "&str",
62+
"expansion": null
63+
}
64+
],
65+
"children": [],
66+
"rendered": null
67+
}
68+
],
69+
"rendered": "warning: Constants have by default a `'static` lifetime\n --> ./tests/fixtures/const_static_lifetime.rs:1:15\n |\n1 | const LOREM: &'static str = \"ipsum\";\n | -^^^^^^^---- help: consider removing `'static`: `&str`\n |\n = note: #[warn(const_static_lifetime)] on by default\n\n"
70+
}
71+
{
72+
"message": "constant item is never used: `LOREM`",
73+
"code": {
74+
"code": "dead_code",
75+
"explanation": null
76+
},
77+
"level": "warning",
78+
"spans": [
79+
{
80+
"file_name": "./tests/fixtures/const_static_lifetime.rs",
81+
"byte_start": 0,
82+
"byte_end": 36,
83+
"line_start": 1,
84+
"line_end": 1,
85+
"column_start": 1,
86+
"column_end": 37,
87+
"is_primary": true,
88+
"text": [
89+
{
90+
"text": "const LOREM: &'static str = \"ipsum\";",
91+
"highlight_start": 1,
92+
"highlight_end": 37
93+
}
94+
],
95+
"label": null,
96+
"suggested_replacement": null,
97+
"expansion": null
98+
}
99+
],
100+
"children": [
101+
{
102+
"message": "#[warn(dead_code)] on by default",
103+
"code": null,
104+
"level": "note",
105+
"spans": [],
106+
"children": [],
107+
"rendered": null
108+
}
109+
],
110+
"rendered": "warning: constant item is never used: `LOREM`\n --> ./tests/fixtures/const_static_lifetime.rs:1:1\n |\n1 | const LOREM: &'static str = \"ipsum\";\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = note: #[warn(dead_code)] on by default\n\n"
111+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const LOREM: &'static str = "ipsum";
2+
3+
fn main() {}
Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
11
{
2-
"message": "it is more idiomatic to loop over references to containers instead of using explicit iteration methods",
3-
"code": {
4-
"code": "explicit_iter_loop",
5-
"explanation": null
2+
"message": "it is more idiomatic to loop over references to containers instead of using explicit iteration methods",
3+
"code": {
4+
"code": "explicit_iter_loop",
5+
"explanation": null
6+
},
7+
"level": "warning",
8+
"spans": [
9+
{
10+
"file_name": "./tests/fixtures/explicit_iter_loop.rs",
11+
"byte_start": 54,
12+
"byte_end": 63,
13+
"line_start": 4,
14+
"line_end": 4,
15+
"column_start": 14,
16+
"column_end": 23,
17+
"is_primary": true,
18+
"text": [
19+
{
20+
"text": " for x in xs.iter() {",
21+
"highlight_start": 14,
22+
"highlight_end": 23
23+
}
24+
],
25+
"label": null,
26+
"suggested_replacement": null,
27+
"expansion": null
28+
}
29+
],
30+
"children": [
31+
{
32+
"message": "#[warn(explicit_iter_loop)] on by default",
33+
"code": null,
34+
"level": "note",
35+
"spans": [],
36+
"children": [],
37+
"rendered": null
638
},
7-
"level": "warning",
8-
"spans": [
9-
{
10-
"file_name": "./tests/fixtures/explicit_iter_loop.rs",
11-
"byte_start": 54,
12-
"byte_end": 63,
13-
"line_start": 4,
14-
"line_end": 4,
15-
"column_start": 14,
16-
"column_end": 23,
17-
"is_primary": true,
18-
"text": [
19-
{
20-
"text": " for x in xs.iter() {",
21-
"highlight_start": 14,
22-
"highlight_end": 23
23-
}
24-
],
25-
"label": null,
26-
"suggested_replacement": null,
27-
"expansion": null
28-
}
29-
],
30-
"children": [
31-
{
32-
"message": "#[warn(explicit_iter_loop)] on by default",
33-
"code": null,
34-
"level": "note",
35-
"spans": [],
36-
"children": [],
37-
"rendered": null
38-
},
39-
{
40-
"message": "to write this more concisely, try",
41-
"code": null,
42-
"level": "help",
43-
"spans": [
44-
{
45-
"file_name": "./tests/fixtures/explicit_iter_loop.rs",
46-
"byte_start": 54,
47-
"byte_end": 63,
48-
"line_start": 4,
49-
"line_end": 4,
50-
"column_start": 14,
51-
"column_end": 23,
52-
"is_primary": true,
53-
"text": [
54-
{
55-
"text": " for x in xs.iter() {",
56-
"highlight_start": 14,
57-
"highlight_end": 23
58-
}
59-
],
60-
"label": null,
61-
"suggested_replacement": "&xs",
62-
"expansion": null
63-
}
64-
],
65-
"children": [],
66-
"rendered": null
67-
}
68-
],
69-
"rendered": "warning: it is more idiomatic to loop over references to containers instead of using explicit iteration methods\n --> ./tests/fixtures/explicit_iter_loop.rs:4:14\n |\n4 | for x in xs.iter() {\n | ^^^^^^^^^ help: to write this more concisely, try: `&xs`\n |\n = note: #[warn(explicit_iter_loop)] on by default\n\n"
70-
}
39+
{
40+
"message": "to write this more concisely, try",
41+
"code": null,
42+
"level": "help",
43+
"spans": [
44+
{
45+
"file_name": "./tests/fixtures/explicit_iter_loop.rs",
46+
"byte_start": 54,
47+
"byte_end": 63,
48+
"line_start": 4,
49+
"line_end": 4,
50+
"column_start": 14,
51+
"column_end": 23,
52+
"is_primary": true,
53+
"text": [
54+
{
55+
"text": " for x in xs.iter() {",
56+
"highlight_start": 14,
57+
"highlight_end": 23
58+
}
59+
],
60+
"label": null,
61+
"suggested_replacement": "&xs",
62+
"expansion": null
63+
}
64+
],
65+
"children": [],
66+
"rendered": null
67+
}
68+
],
69+
"rendered": "warning: it is more idiomatic to loop over references to containers instead of using explicit iteration methods\n --> ./tests/fixtures/explicit_iter_loop.rs:4:14\n |\n4 | for x in xs.iter() {\n | ^^^^^^^^^ help: to write this more concisely, try: `&xs`\n |\n = note: #[warn(explicit_iter_loop)] on by default\n\n"
70+
}

tests/fixtures/lt-generic-comp.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
],
4747
"children": [
4848
{
49-
"message": "try comparing the casted value",
49+
"message": "try comparing the cast value",
5050
"code": null,
5151
"level": "help",
5252
"spans": [
@@ -75,7 +75,7 @@
7575
"rendered": null
7676
}
7777
],
78-
"rendered": "error: `<` is interpreted as a start of generic arguments for `u32`, not a comparison\n --> ./tests/fixtures/lt-generic-comp.rs:4:17\n |\n4 | if x as u32 < 4 {\n | -------- ^ - interpreted as generic arguments\n | | |\n | | not interpreted as comparison\n | help: try comparing the casted value: `(x as u32)`\n\n"
78+
"rendered": "error: `<` is interpreted as a start of generic arguments for `u32`, not a comparison\n --> ./tests/fixtures/lt-generic-comp.rs:4:17\n |\n4 | if x as u32 < 4 {\n | -------- ^ - interpreted as generic arguments\n | | |\n | | not interpreted as comparison\n | help: try comparing the cast value: `(x as u32)`\n\n"
7979
}
8080
{
8181
"message": "aborting due to previous error",

tests/fixtures/redundant_closure_call.fixed.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(unused_variables)]
12
fn main() {
23
let a = 42;
34

0 commit comments

Comments
 (0)