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

Commit ad382da

Browse files
committed
Add test for edition lint
1 parent 74df290 commit ad382da

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed

tests/edition/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.recorded.json
2+
*.recorded.rs

tests/edition/pub_crate.fixed.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![allow(unused)]
2+
#[warn(rust_2018_migration)]
3+
4+
mod private_mod {
5+
crate const FOO: &str = "BAR";
6+
}
7+
8+
fn main() {}

tests/edition/pub_crate.json

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"message": "unreachable `pub` item",
3+
"code": {
4+
"code": "unreachable_pub",
5+
"explanation": null
6+
},
7+
"level": "warning",
8+
"spans": [
9+
{
10+
"file_name": "./tests/edition/pub_crate.rs",
11+
"byte_start": 70,
12+
"byte_end": 98,
13+
"line_start": 5,
14+
"line_end": 5,
15+
"column_start": 5,
16+
"column_end": 33,
17+
"is_primary": true,
18+
"text": [
19+
{
20+
"text": " pub const FOO: &str = \"BAR\";",
21+
"highlight_start": 5,
22+
"highlight_end": 33
23+
}
24+
],
25+
"label": null,
26+
"suggested_replacement": null,
27+
"expansion": null
28+
}
29+
],
30+
"children": [
31+
{
32+
"message": "lint level defined here",
33+
"code": null,
34+
"level": "note",
35+
"spans": [
36+
{
37+
"file_name": "./tests/edition/pub_crate.rs",
38+
"byte_start": 25,
39+
"byte_end": 44,
40+
"line_start": 2,
41+
"line_end": 2,
42+
"column_start": 8,
43+
"column_end": 27,
44+
"is_primary": true,
45+
"text": [
46+
{
47+
"text": "#[warn(rust_2018_migration)]",
48+
"highlight_start": 8,
49+
"highlight_end": 27
50+
}
51+
],
52+
"label": null,
53+
"suggested_replacement": null,
54+
"expansion": null
55+
}
56+
],
57+
"children": [],
58+
"rendered": null
59+
},
60+
{
61+
"message": "#[warn(unreachable_pub)] implied by #[warn(rust_2018_migration)]",
62+
"code": null,
63+
"level": "note",
64+
"spans": [],
65+
"children": [],
66+
"rendered": null
67+
},
68+
{
69+
"message": "or consider exporting it for use by other crates",
70+
"code": null,
71+
"level": "help",
72+
"spans": [],
73+
"children": [],
74+
"rendered": null
75+
},
76+
{
77+
"message": "consider restricting its visibility",
78+
"code": null,
79+
"level": "help",
80+
"spans": [
81+
{
82+
"file_name": "./tests/edition/pub_crate.rs",
83+
"byte_start": 70,
84+
"byte_end": 73,
85+
"line_start": 5,
86+
"line_end": 5,
87+
"column_start": 5,
88+
"column_end": 8,
89+
"is_primary": true,
90+
"text": [
91+
{
92+
"text": " pub const FOO: &str = \"BAR\";",
93+
"highlight_start": 5,
94+
"highlight_end": 8
95+
}
96+
],
97+
"label": null,
98+
"suggested_replacement": "crate",
99+
"suggestion_applicability": "MachineApplicable",
100+
"expansion": null
101+
}
102+
],
103+
"children": [],
104+
"rendered": null
105+
}
106+
],
107+
"rendered": "warning: unreachable `pub` item\n --> ./tests/edition/pub_crate.rs:5:5\n |\n5 | pub const FOO: &str = \"BAR\";\n | ---^^^^^^^^^^^^^^^^^^^^^^^^^\n | |\n | help: consider restricting its visibility: `crate`\n |\nnote: lint level defined here\n --> ./tests/edition/pub_crate.rs:2:8\n |\n2 | #[warn(rust_2018_migration)]\n | ^^^^^^^^^^^^^^^^^^^\n = note: #[warn(unreachable_pub)] implied by #[warn(rust_2018_migration)]\n = help: or consider exporting it for use by other crates\n\n"
108+
}

tests/edition/pub_crate.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![allow(unused)]
2+
#[warn(rust_2018_migration)]
3+
4+
mod private_mod {
5+
pub const FOO: &str = "BAR";
6+
}
7+
8+
fn main() {}

tests/parse_and_replace.rs

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ fn everything() {
232232
}
233233

234234
#[test]
235+
#[ignore = "Requires custom rustc build"]
235236
fn edition() {
236237
let _ = env_logger::try_init();
237238
assert_fixtures("./tests/edition", fixmode::EDITION);

0 commit comments

Comments
 (0)