Skip to content

Commit 340599c

Browse files
committed
Expand and improve auto-correct tests
1 parent d903519 commit 340599c

File tree

11 files changed

+844
-20
lines changed

11 files changed

+844
-20
lines changed

Cargo.lock

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ serde = "1.0"
5050
serde-untagged = "0.1"
5151
serde_json = "1.0"
5252
similar-asserts = "1.7"
53+
snapbox = "0.6"
5354
syntect = { version = "5.3", default-features = false }
5455
tar = "0.4"
5556
tempfile = "3.23"

cargo-dylint/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ regex = { workspace = true }
3232
semver = { workspace = true }
3333
serde_json = { workspace = true }
3434
similar-asserts = { workspace = true }
35+
snapbox = { workspace = true }
3536
tempfile = { workspace = true }
3637
walkdir = { workspace = true }
3738

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Warning: `env_logger` already initialized: attempted to set a logger after the logging system was already initialized
2+
Cloning into '[..]'...
3+
Checking upgraded library package
4+
Found 0 highlights in [..] seconds
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Warning: `env_logger` already initialized: attempted to set a logger after the logging system was already initialized
2+
Cloning into '[..]'...
3+
Checking upgraded library package
4+
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
5+
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
6+
Warning: Found diagnostic error with no spans: aborting due to 2 previous errors
7+
Found 6 highlights in [..] seconds
8+
Found 460 commits in [..] seconds
9+
Found 2251 patches in [..] seconds
10+
Extracted 841 rewrite rules in [..] seconds (discarded 1951 insertions and 429 refactors)
11+
Rewriting with score 5 rewrite from 379342c: Rewrite {
12+
before_tokens: "[[..]]",
13+
rewrite: "[/"hir/", /"(/", /")/", /"./", /"get_parent/"] -> [/"parent_hir_node/"]",
14+
after_tokens: "[[..]]",
15+
} Highlight {
16+
message: "no method named `get_parent` found for struct `rustc_middle::hir::map::Map` in the current scope",
17+
file_name: "overscoped_allow/src/lib.rs",
18+
line_start: 206,
19+
line_end: 209,
20+
lines: [
21+
" if let Node::TraitItem(trait_item) = cx",
22+
" .tcx",
23+
" .hir()",
24+
" .get_parent(cx.tcx.hir().parent_id(block.hir_id))",
25+
],
26+
highlight_start: 9,
27+
highlight_end: 16,
28+
is_primary: false,
29+
..
30+
}
31+
Rewriting with score 9 rewrite from 379342c: Rewrite {
32+
before_tokens: "[/"let/", /"parent /", /"=/", /"cx.tcx./"]",
33+
rewrite: "[/"hir/", /"(/", /")/", /"./", /"get_parent/"] -> [/"parent_hir_node/"]",
34+
after_tokens: "[/"(/", /"expr.hir_id/", /")/", /";/"]",
35+
} Highlight {
36+
message: "no method named `get_parent` found for struct `rustc_middle::hir::map::Map` in the current scope",
37+
file_name: "suboptimal_pattern/src/lib.rs",
38+
line_start: 206,
39+
line_end: 206,
40+
lines: [
41+
" let node = self.tcx.hir().get_parent(expr.hir_id);",
42+
],
43+
highlight_start: 9,
44+
highlight_end: 10,
45+
is_primary: true,
46+
..
47+
}
48+
Rewriting with score 8 rewrite from 9d6f416: Rewrite {
49+
before_tokens: "[/"if/", /"let/", /"StmtKind/", /"::/"]",
50+
rewrite: "[/"Local/"] -> [/"Let/"]",
51+
after_tokens: "[/"(/", /"Local /", /"{/"]",
52+
} Highlight {
53+
message: "no variant or associated item named `Local` found for enum `rustc_hir::StmtKind` in the current scope",
54+
file_name: "misleading_variable_name/src/lib.rs",
55+
line_start: 55,
56+
line_end: 55,
57+
lines: [
58+
" if let StmtKind::Local(Local {",
59+
],
60+
highlight_start: 4,
61+
highlight_end: 5,
62+
is_primary: true,
63+
..
64+
}
65+
Checking upgraded library package
66+
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
67+
Found 1 highlights in [..] seconds
68+
Rewriting with score 6 rewrite from 379342c: Rewrite {
69+
before_tokens: "[[..]]",
70+
rewrite: "[/"hir/", /"(/", /")/", /"./", /"parent_id/"] -> [/"parent_hir_id/"]",
71+
after_tokens: "[[..]]",
72+
} Highlight {
73+
message: "no method named `parent_id` found for struct `rustc_middle::hir::map::Map` in the current scope",
74+
file_name: "overscoped_allow/src/lib.rs",
75+
line_start: 208,
76+
line_end: 208,
77+
lines: [
78+
" .parent_hir_node(cx.tcx.hir().parent_id(block.hir_id))",
79+
],
80+
highlight_start: 8,
81+
highlight_end: 9,
82+
is_primary: true,
83+
..
84+
}
85+
Checking upgraded library package
86+
Found 0 highlights in [..] seconds
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
Warning: `env_logger` already initialized: attempted to set a logger after the logging system was already initialized
2+
Cloning into '[..]'...
3+
Checking upgraded library package
4+
Found 3 highlights in [..] seconds
5+
Found 422 commits in [..] seconds
6+
Found 1802 patches in [..] seconds
7+
Extracted 722 rewrite rules in [..] seconds (discarded 1275 insertions and 524 refactors)
8+
Rewriting with score 3 rewrite from 20ce69b: Rewrite {
9+
before_tokens: "[/"use/", /"rustc_middle/", /"::/", /"ty/", /"::/"]",
10+
rewrite: "[/"AssocItemContainer/"] -> [/"AssocContainer/"]",
11+
after_tokens: "[/";/"]",
12+
} Highlight {
13+
message: "failed to resolve: could not find `AssocItemContainer` in `ty`",
14+
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
15+
line_start: 389,
16+
line_end: 389,
17+
lines: [
18+
" ty::AssocItemContainer::Trait => cx.tcx.def_path_str(def_id),",
19+
],
20+
highlight_start: 2,
21+
highlight_end: 3,
22+
is_primary: true,
23+
..
24+
}
25+
Rewriting with score 3 rewrite from 20ce69b: Rewrite {
26+
before_tokens: "[/"use/", /"rustc_middle/", /"::/", /"ty/", /"::/"]",
27+
rewrite: "[/"AssocItemContainer/"] -> [/"AssocContainer/"]",
28+
after_tokens: "[/";/"]",
29+
} Highlight {
30+
message: "failed to resolve: could not find `AssocItemContainer` in `ty`",
31+
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
32+
line_start: 390,
33+
line_end: 390,
34+
lines: [
35+
" ty::AssocItemContainer::Impl => {",
36+
],
37+
highlight_start: 2,
38+
highlight_end: 3,
39+
is_primary: true,
40+
..
41+
}
42+
Rewriting with score 1 rewrite from 2d3efb0: Rewrite {
43+
before_tokens: "[/"&/", /"&/"]",
44+
rewrite: "[/"peel_middle_ty_refs/"] -> [/"peel_and_count_ty_refs/"]",
45+
after_tokens: "[/"(/", /"arg_ty/", /")/", /"./", /"1/", /">/", /"1/"]",
46+
} Highlight {
47+
message: "unresolved import `clippy_utils::peel_middle_ty_refs`",
48+
file_name: "suboptimal_pattern/src/lib.rs",
49+
line_start: 11,
50+
line_end: 11,
51+
lines: [
52+
" diagnostics::span_lint_and_sugg, path_to_local_id, peel_middle_ty_refs, source::snippet,",
53+
],
54+
highlight_start: 6,
55+
highlight_end: 7,
56+
is_primary: true,
57+
..
58+
}
59+
Checking upgraded library package
60+
Found 3 highlights in [..] seconds
61+
Rewriting with score 4 rewrite from 2d3efb0: Rewrite {
62+
before_tokens: "[[..]]",
63+
rewrite: "[/")/", /"=/", /"peel_middle_ty_refs/"] -> [/",/", /"_/", /")/", /"=/", /"peel_and_count_ty_refs/"]",
64+
after_tokens: "[[..]]",
65+
} Highlight {
66+
message: "cannot find function `peel_middle_ty_refs` in this scope",
67+
file_name: "suboptimal_pattern/src/lib.rs",
68+
line_start: 137,
69+
line_end: 137,
70+
lines: [
71+
" let (referent_ty, n_refs) = peel_middle_ty_refs(pat_ty);",
72+
],
73+
highlight_start: 7,
74+
highlight_end: 8,
75+
is_primary: true,
76+
..
77+
}
78+
Rewriting with score 6 rewrite from 324c214: Rewrite {
79+
before_tokens: "[/"rustc_ty/", /"::/", /"AssocContainer/", /"::/"]",
80+
rewrite: "[/"Impl /"] -> [/"InherentImpl /", /"|/", /"rustc_ty/", /"::/", /"AssocContainer/", /"::/", /"TraitImpl/", /"(/", /"_/", /")/"]",
81+
after_tokens: "[/"=>/", /"{/"]",
82+
} Highlight {
83+
message: "no variant or associated item named `Impl` found for enum `AssocContainer` in the current scope",
84+
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
85+
line_start: 390,
86+
line_end: 390,
87+
lines: [
88+
" ty::AssocContainer::Impl => {",
89+
],
90+
highlight_start: 4,
91+
highlight_end: 5,
92+
is_primary: true,
93+
..
94+
}
95+
Checking upgraded library package
96+
Found 2 highlights in [..] seconds
97+
Found no applicable rewrites for Highlight {
98+
message: "failed to resolve: use of unresolved module or unlinked crate `rustc_ty`",
99+
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
100+
line_start: 390,
101+
line_end: 390,
102+
lines: [
103+
" ty::AssocContainer::InherentImpl | rustc_ty::AssocContainer::TraitImpl(_)=> {",
104+
],
105+
highlight_start: 6,
106+
highlight_end: 7,
107+
is_primary: true,
108+
..
109+
}
110+
Found no applicable rewrites for Highlight {
111+
message: "unresolved import `clippy_utils::peel_and_count_ty_refs`",
112+
file_name: "suboptimal_pattern/src/lib.rs",
113+
line_start: 11,
114+
line_end: 11,
115+
lines: [
116+
" diagnostics::span_lint_and_sugg, path_to_local_id, peel_and_count_ty_refs, source::snippet,",
117+
],
118+
highlight_start: 6,
119+
highlight_end: 7,
120+
is_primary: true,
121+
..
122+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
Warning: `env_logger` already initialized: attempted to set a logger after the logging system was already initialized
2+
Cloning into '[..]'...
3+
Checking upgraded library package
4+
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
5+
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
6+
Found 2 highlights in [..] seconds
7+
Found 127 commits in [..] seconds
8+
Found 621 patches in [..] seconds
9+
Extracted 293 rewrite rules in [..] seconds (discarded 370 insertions and 58 refactors)
10+
Rewriting with score 17 rewrite from 1325425: Rewrite {
11+
before_tokens: "[/"use/", /"rustc_hir/", /"::/", /"{/"]",
12+
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
13+
after_tokens: "[/",/", /"Expr/", /",/", /"ExprKind/", /",/", /"FnRetTy/", /",/", /"Param/", /",/", /"PatKind/", /",/", /"QPath/", /",/", /"TyKind/", /",/", /"Unsafety/", /"}/", /";/"]",
14+
} Highlight {
15+
message: "unresolved import `rustc_hir::BindingAnnotation`",
16+
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
17+
line_start: 28,
18+
line_end: 28,
19+
lines: [
20+
" BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety,",
21+
],
22+
highlight_start: 0,
23+
highlight_end: 1,
24+
is_primary: true,
25+
..
26+
}
27+
Rewriting with score 12 rewrite from 1325425: Rewrite {
28+
before_tokens: "[/"BinOpKind/", /",/"]",
29+
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
30+
after_tokens: "[/",/", /"Body/", /",/", /"ByRef/", /",/", /"Expr/", /",/", /"ExprKind/", /",/", /"FnDecl/", /",/", /"Mutability/", /",/", /"PatKind/", /",/", /"QPath/", /",/", /"Stmt/", /",/", /"StmtKind/", /",/"]",
31+
} Highlight {
32+
message: "unresolved import `rustc_hir::BindingAnnotation`",
33+
file_name: "suboptimal_pattern/src/lib.rs",
34+
line_start: 22,
35+
line_end: 22,
36+
lines: [
37+
" BindingAnnotation, Body, ByRef, Expr, ExprKind, FnDecl, HirId, Node, Pat, PatKind, UnOp,",
38+
],
39+
highlight_start: 0,
40+
highlight_end: 1,
41+
is_primary: true,
42+
..
43+
}
44+
Checking upgraded library package
45+
Warning: Found diagnostic error with no spans: aborting due to 3 previous errors; 1 warning emitted
46+
Warning: Found diagnostic error with no spans: aborting due to 2 previous errors
47+
Found 6 highlights in [..] seconds
48+
Rewriting with score 13 rewrite from 1325425: Rewrite {
49+
before_tokens: "[/"&/", /"&/", /"let/", /"PatKind/", /"::/", /"Binding/", /"(/"]",
50+
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
51+
after_tokens: "[/"(/", /"ByRef/", /"::/", /"No/", /",/", /"mutability/", /")/", /",/", /"_/", /",/", /"ident/", /",/", /"None/", /")/", /"=/", /"local.pat.kind/"]",
52+
} Highlight {
53+
message: "cannot find tuple struct or tuple variant `BindingAnnotation` in this scope",
54+
file_name: "suboptimal_pattern/src/lib.rs",
55+
line_start: 124,
56+
line_end: 124,
57+
lines: [
58+
" && let PatKind::Binding(BindingAnnotation(ByRef::No, _), hir_id, ident, None) =",
59+
],
60+
highlight_start: 7,
61+
highlight_end: 8,
62+
is_primary: true,
63+
..
64+
}
65+
Rewriting with score 6 rewrite from 1325425: Rewrite {
66+
before_tokens: "[[..]]",
67+
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
68+
after_tokens: "[[..]]",
69+
} Highlight {
70+
message: "cannot find tuple struct or tuple variant `BindingAnnotation` in this scope",
71+
file_name: "suboptimal_pattern/src/lib.rs",
72+
line_start: 256,
73+
line_end: 256,
74+
lines: [
75+
" BindingAnnotation(ByRef::No, _) => {",
76+
],
77+
highlight_start: 0,
78+
highlight_end: 1,
79+
is_primary: true,
80+
..
81+
}
82+
Rewriting with score 11 rewrite from 1325425: Rewrite {
83+
before_tokens: "[[..]]",
84+
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
85+
after_tokens: "[[..]]",
86+
} Highlight {
87+
message: "cannot find tuple struct or tuple variant `BindingAnnotation` in this scope",
88+
file_name: "suboptimal_pattern/src/lib.rs",
89+
line_start: 259,
90+
line_end: 259,
91+
lines: [
92+
" BindingAnnotation(ByRef::Yes(_), _) => {",
93+
],
94+
highlight_start: 0,
95+
highlight_end: 1,
96+
is_primary: true,
97+
..
98+
}
99+
Rewriting with score 10 rewrite from 1325425: Rewrite {
100+
before_tokens: "[/"if/", /"let/", /"PatKind/", /"::/", /"Binding/", /"(/"]",
101+
rewrite: "[/"BindingAnnotation/", /"::/", /"NONE/", /"|/", /"BindingAnnotation/"] -> [/"BindingMode/", /"::/", /"NONE/", /"|/", /"BindingMode/"]",
102+
after_tokens: "[/"::/", /"MUT/", /",/", /"id/", /",/", /"_/", /",/", /"None/", /")/", /"=/", /"l.pat.kind/"]",
103+
} Highlight {
104+
message: "failed to resolve: use of undeclared type `BindingAnnotation`",
105+
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
106+
line_start: 250,
107+
line_end: 250,
108+
lines: [
109+
" PatKind::Binding(BindingAnnotation::NONE | BindingAnnotation::MUT, id, _, None)",
110+
],
111+
highlight_start: 4,
112+
highlight_end: 5,
113+
is_primary: true,
114+
..
115+
}
116+
Checking upgraded library package
117+
Found 0 highlights in [..] seconds

0 commit comments

Comments
 (0)