Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ serde = "1.0"
serde-untagged = "0.1"
serde_json = "1.0"
similar-asserts = "1.7"
snapbox = "0.6"
syntect = { version = "5.3", default-features = false }
tar = "0.4"
tempfile = "3.23"
Expand Down
1 change: 1 addition & 0 deletions cargo-dylint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ regex = { workspace = true }
semver = { workspace = true }
serde_json = { workspace = true }
similar-asserts = { workspace = true }
snapbox = { workspace = true }
tempfile = { workspace = true }
walkdir = { workspace = true }

Expand Down
4 changes: 4 additions & 0 deletions cargo-dylint/tests/integration/auto_correct/1e03ecf.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Warning: `env_logger` already initialized: attempted to set a logger after the logging system was already initialized
Cloning into '[..]'...
Checking upgraded library package
Found 0 highlights in [..] seconds
86 changes: 86 additions & 0 deletions cargo-dylint/tests/integration/auto_correct/23c08c8.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Warning: `env_logger` already initialized: attempted to set a logger after the logging system was already initialized
Cloning into '[..]'...
Checking upgraded library package
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
Warning: Found diagnostic error with no spans: aborting due to 2 previous errors
Found 6 highlights in [..] seconds
Found 460 commits in [..] seconds
Found 2251 patches in [..] seconds
Extracted 841 rewrite rules in [..] seconds (discarded 1951 insertions and 429 refactors)
Rewriting with score 5 rewrite from 379342c: Rewrite {
before_tokens: "[[..]]",
rewrite: "[/"hir/", /"(/", /")/", /"./", /"get_parent/"] -> [/"parent_hir_node/"]",
after_tokens: "[[..]]",
} Highlight {
message: "no method named `get_parent` found for struct `rustc_middle::hir::map::Map` in the current scope",
file_name: "overscoped_allow/src/lib.rs",
line_start: 206,
line_end: 209,
lines: [
" if let Node::TraitItem(trait_item) = cx",
" .tcx",
" .hir()",
" .get_parent(cx.tcx.hir().parent_id(block.hir_id))",
],
highlight_start: 9,
highlight_end: 16,
is_primary: false,
..
}
Rewriting with score 9 rewrite from 379342c: Rewrite {
before_tokens: "[/"let/", /"parent /", /"=/", /"cx.tcx./"]",
rewrite: "[/"hir/", /"(/", /")/", /"./", /"get_parent/"] -> [/"parent_hir_node/"]",
after_tokens: "[/"(/", /"expr.hir_id/", /")/", /";/"]",
} Highlight {
message: "no method named `get_parent` found for struct `rustc_middle::hir::map::Map` in the current scope",
file_name: "suboptimal_pattern/src/lib.rs",
line_start: 206,
line_end: 206,
lines: [
" let node = self.tcx.hir().get_parent(expr.hir_id);",
],
highlight_start: 9,
highlight_end: 10,
is_primary: true,
..
}
Rewriting with score 8 rewrite from 9d6f416: Rewrite {
before_tokens: "[/"if/", /"let/", /"StmtKind/", /"::/"]",
rewrite: "[/"Local/"] -> [/"Let/"]",
after_tokens: "[/"(/", /"Local /", /"{/"]",
} Highlight {
message: "no variant or associated item named `Local` found for enum `rustc_hir::StmtKind` in the current scope",
file_name: "misleading_variable_name/src/lib.rs",
line_start: 55,
line_end: 55,
lines: [
" if let StmtKind::Local(Local {",
],
highlight_start: 4,
highlight_end: 5,
is_primary: true,
..
}
Checking upgraded library package
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
Found 1 highlights in [..] seconds
Rewriting with score 6 rewrite from 379342c: Rewrite {
before_tokens: "[[..]]",
rewrite: "[/"hir/", /"(/", /")/", /"./", /"parent_id/"] -> [/"parent_hir_id/"]",
after_tokens: "[[..]]",
} Highlight {
message: "no method named `parent_id` found for struct `rustc_middle::hir::map::Map` in the current scope",
file_name: "overscoped_allow/src/lib.rs",
line_start: 208,
line_end: 208,
lines: [
" .parent_hir_node(cx.tcx.hir().parent_id(block.hir_id))",
],
highlight_start: 8,
highlight_end: 9,
is_primary: true,
..
}
Checking upgraded library package
Found 0 highlights in [..] seconds
122 changes: 122 additions & 0 deletions cargo-dylint/tests/integration/auto_correct/5343770.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
Warning: `env_logger` already initialized: attempted to set a logger after the logging system was already initialized
Cloning into '[..]'...
Checking upgraded library package
Found 3 highlights in [..] seconds
Found 422 commits in [..] seconds
Found 1802 patches in [..] seconds
Extracted 722 rewrite rules in [..] seconds (discarded 1275 insertions and 524 refactors)
Rewriting with score 3 rewrite from 20ce69b: Rewrite {
before_tokens: "[/"use/", /"rustc_middle/", /"::/", /"ty/", /"::/"]",
rewrite: "[/"AssocItemContainer/"] -> [/"AssocContainer/"]",
after_tokens: "[/";/"]",
} Highlight {
message: "failed to resolve: could not find `AssocItemContainer` in `ty`",
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
line_start: 389,
line_end: 389,
lines: [
" ty::AssocItemContainer::Trait => cx.tcx.def_path_str(def_id),",
],
highlight_start: 2,
highlight_end: 3,
is_primary: true,
..
}
Rewriting with score 3 rewrite from 20ce69b: Rewrite {
before_tokens: "[/"use/", /"rustc_middle/", /"::/", /"ty/", /"::/"]",
rewrite: "[/"AssocItemContainer/"] -> [/"AssocContainer/"]",
after_tokens: "[/";/"]",
} Highlight {
message: "failed to resolve: could not find `AssocItemContainer` in `ty`",
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
line_start: 390,
line_end: 390,
lines: [
" ty::AssocItemContainer::Impl => {",
],
highlight_start: 2,
highlight_end: 3,
is_primary: true,
..
}
Rewriting with score 1 rewrite from 2d3efb0: Rewrite {
before_tokens: "[/"&/", /"&/"]",
rewrite: "[/"peel_middle_ty_refs/"] -> [/"peel_and_count_ty_refs/"]",
after_tokens: "[/"(/", /"arg_ty/", /")/", /"./", /"1/", /">/", /"1/"]",
} Highlight {
message: "unresolved import `clippy_utils::peel_middle_ty_refs`",
file_name: "suboptimal_pattern/src/lib.rs",
line_start: 11,
line_end: 11,
lines: [
" diagnostics::span_lint_and_sugg, path_to_local_id, peel_middle_ty_refs, source::snippet,",
],
highlight_start: 6,
highlight_end: 7,
is_primary: true,
..
}
Checking upgraded library package
Found 3 highlights in [..] seconds
Rewriting with score 4 rewrite from 2d3efb0: Rewrite {
before_tokens: "[[..]]",
rewrite: "[/")/", /"=/", /"peel_middle_ty_refs/"] -> [/",/", /"_/", /")/", /"=/", /"peel_and_count_ty_refs/"]",
after_tokens: "[[..]]",
} Highlight {
message: "cannot find function `peel_middle_ty_refs` in this scope",
file_name: "suboptimal_pattern/src/lib.rs",
line_start: 137,
line_end: 137,
lines: [
" let (referent_ty, n_refs) = peel_middle_ty_refs(pat_ty);",
],
highlight_start: 7,
highlight_end: 8,
is_primary: true,
..
}
Rewriting with score 6 rewrite from 324c214: Rewrite {
before_tokens: "[/"rustc_ty/", /"::/", /"AssocContainer/", /"::/"]",
rewrite: "[/"Impl /"] -> [/"InherentImpl /", /"|/", /"rustc_ty/", /"::/", /"AssocContainer/", /"::/", /"TraitImpl/", /"(/", /"_/", /")/"]",
after_tokens: "[/"=>/", /"{/"]",
} Highlight {
message: "no variant or associated item named `Impl` found for enum `AssocContainer` in the current scope",
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
line_start: 390,
line_end: 390,
lines: [
" ty::AssocContainer::Impl => {",
],
highlight_start: 4,
highlight_end: 5,
is_primary: true,
..
}
Checking upgraded library package
Found 2 highlights in [..] seconds
Found no applicable rewrites for Highlight {
message: "failed to resolve: use of unresolved module or unlinked crate `rustc_ty`",
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
line_start: 390,
line_end: 390,
lines: [
" ty::AssocContainer::InherentImpl | rustc_ty::AssocContainer::TraitImpl(_)=> {",
],
highlight_start: 6,
highlight_end: 7,
is_primary: true,
..
}
Found no applicable rewrites for Highlight {
message: "unresolved import `clippy_utils::peel_and_count_ty_refs`",
file_name: "suboptimal_pattern/src/lib.rs",
line_start: 11,
line_end: 11,
lines: [
" diagnostics::span_lint_and_sugg, path_to_local_id, peel_and_count_ty_refs, source::snippet,",
],
highlight_start: 6,
highlight_end: 7,
is_primary: true,
..
}
117 changes: 117 additions & 0 deletions cargo-dylint/tests/integration/auto_correct/5b37925.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
Warning: `env_logger` already initialized: attempted to set a logger after the logging system was already initialized
Cloning into '[..]'...
Checking upgraded library package
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
Warning: Found diagnostic error with no spans: aborting due to 1 previous error
Found 2 highlights in [..] seconds
Found 127 commits in [..] seconds
Found 621 patches in [..] seconds
Extracted 293 rewrite rules in [..] seconds (discarded 370 insertions and 58 refactors)
Rewriting with score 17 rewrite from 1325425: Rewrite {
before_tokens: "[/"use/", /"rustc_hir/", /"::/", /"{/"]",
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
after_tokens: "[/",/", /"Expr/", /",/", /"ExprKind/", /",/", /"FnRetTy/", /",/", /"Param/", /",/", /"PatKind/", /",/", /"QPath/", /",/", /"TyKind/", /",/", /"Unsafety/", /"}/", /";/"]",
} Highlight {
message: "unresolved import `rustc_hir::BindingAnnotation`",
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
line_start: 28,
line_end: 28,
lines: [
" BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety,",
],
highlight_start: 0,
highlight_end: 1,
is_primary: true,
..
}
Rewriting with score 12 rewrite from 1325425: Rewrite {
before_tokens: "[/"BinOpKind/", /",/"]",
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
after_tokens: "[/",/", /"Body/", /",/", /"ByRef/", /",/", /"Expr/", /",/", /"ExprKind/", /",/", /"FnDecl/", /",/", /"Mutability/", /",/", /"PatKind/", /",/", /"QPath/", /",/", /"Stmt/", /",/", /"StmtKind/", /",/"]",
} Highlight {
message: "unresolved import `rustc_hir::BindingAnnotation`",
file_name: "suboptimal_pattern/src/lib.rs",
line_start: 22,
line_end: 22,
lines: [
" BindingAnnotation, Body, ByRef, Expr, ExprKind, FnDecl, HirId, Node, Pat, PatKind, UnOp,",
],
highlight_start: 0,
highlight_end: 1,
is_primary: true,
..
}
Checking upgraded library package
Warning: Found diagnostic error with no spans: aborting due to 3 previous errors; 1 warning emitted
Warning: Found diagnostic error with no spans: aborting due to 2 previous errors
Found 6 highlights in [..] seconds
Rewriting with score 13 rewrite from 1325425: Rewrite {
before_tokens: "[/"&/", /"&/", /"let/", /"PatKind/", /"::/", /"Binding/", /"(/"]",
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
after_tokens: "[/"(/", /"ByRef/", /"::/", /"No/", /",/", /"mutability/", /")/", /",/", /"_/", /",/", /"ident/", /",/", /"None/", /")/", /"=/", /"local.pat.kind/"]",
} Highlight {
message: "cannot find tuple struct or tuple variant `BindingAnnotation` in this scope",
file_name: "suboptimal_pattern/src/lib.rs",
line_start: 124,
line_end: 124,
lines: [
" && let PatKind::Binding(BindingAnnotation(ByRef::No, _), hir_id, ident, None) =",
],
highlight_start: 7,
highlight_end: 8,
is_primary: true,
..
}
Rewriting with score 6 rewrite from 1325425: Rewrite {
before_tokens: "[[..]]",
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
after_tokens: "[[..]]",
} Highlight {
message: "cannot find tuple struct or tuple variant `BindingAnnotation` in this scope",
file_name: "suboptimal_pattern/src/lib.rs",
line_start: 256,
line_end: 256,
lines: [
" BindingAnnotation(ByRef::No, _) => {",
],
highlight_start: 0,
highlight_end: 1,
is_primary: true,
..
}
Rewriting with score 11 rewrite from 1325425: Rewrite {
before_tokens: "[[..]]",
rewrite: "[/"BindingAnnotation/"] -> [/"BindingMode/"]",
after_tokens: "[[..]]",
} Highlight {
message: "cannot find tuple struct or tuple variant `BindingAnnotation` in this scope",
file_name: "suboptimal_pattern/src/lib.rs",
line_start: 259,
line_end: 259,
lines: [
" BindingAnnotation(ByRef::Yes(_), _) => {",
],
highlight_start: 0,
highlight_end: 1,
is_primary: true,
..
}
Rewriting with score 10 rewrite from 1325425: Rewrite {
before_tokens: "[/"if/", /"let/", /"PatKind/", /"::/", /"Binding/", /"(/"]",
rewrite: "[/"BindingAnnotation/", /"::/", /"NONE/", /"|/", /"BindingAnnotation/"] -> [/"BindingMode/", /"::/", /"NONE/", /"|/", /"BindingMode/"]",
after_tokens: "[/"::/", /"MUT/", /",/", /"id/", /",/", /"_/", /",/", /"None/", /")/", /"=/", /"l.pat.kind/"]",
} Highlight {
message: "failed to resolve: use of undeclared type `BindingAnnotation`",
file_name: "ref_aware_redundant_closure_for_method_calls/src/lib.rs",
line_start: 250,
line_end: 250,
lines: [
" PatKind::Binding(BindingAnnotation::NONE | BindingAnnotation::MUT, id, _, None)",
],
highlight_start: 4,
highlight_end: 5,
is_primary: true,
..
}
Checking upgraded library package
Found 0 highlights in [..] seconds
Loading
Loading