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

Commit bc2efef

Browse files
committed
Add const static lifetime test
This is broken right no because of the stray space after the `&`
1 parent f212450 commit bc2efef

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed
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": 14,
47+
"byte_end": 21,
48+
"line_start": 1,
49+
"line_end": 1,
50+
"column_start": 15,
51+
"column_end": 22,
52+
"is_primary": true,
53+
"text": [
54+
{
55+
"text": "const LOREM: &'static str = \"ipsum\";",
56+
"highlight_start": 15,
57+
"highlight_end": 22
58+
}
59+
],
60+
"label": null,
61+
"suggested_replacement": "",
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`\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() {}

0 commit comments

Comments
 (0)