Skip to content

Commit

Permalink
feat: New lint trait_no_longer_object_safe (#659)
Browse files Browse the repository at this point in the history
* feat: adds new lint for trait object no longer safe

* feat: adds new lint for trait object no longer safe

* debugging test failures

* adjust output

* adjust query and output

* adjust doc

* chore: remove object safe trait tests

* chore: remove from macro

* chore: minor nit fixes for the lint query

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
  • Loading branch information
devanbenz and obi1kenobi authored Feb 13, 2024
1 parent 9d5345f commit fc486f2
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/lints/trait_no_longer_object_safe.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SemverQuery(
id: "trait_no_longer_object_safe",
human_readable_name: "trait no longer object safe",
description: "A trait is no longer object safe, meaning it can no longer be used as `dyn Trait`.",
required_update: Major,
reference_link: Some("https://doc.rust-lang.org/stable/reference/items/traits.html#object-safety"),
query: r#"
{
CrateDiff {
baseline {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"]) @output
object_safe @filter(op: "=", value: ["$true"])
importable_path {
path @output @tag
public_api @filter(op: "=", value: ["$true"])
}
}
}
}
current {
item {
... on Trait {
visibility_limit @filter(op: "=", value: ["$public"])
name @output
object_safe @filter(op: "!=", value: ["$true"])
importable_path {
path @filter(op: "=", value: ["%path"])
public_api @filter(op: "=", value: ["$true"])
}
span_: span @optional {
filename @output
begin_line @output
}
}
}
}
}
}"#,
arguments: {
"public": "public",
"true": true,
},
error_message: "Trait is no longer object safe, which breaks `dyn Trait` usage.",
per_result_error_template: Some("trait {{trait_name}} in file {{span_filename}}:{{span_begin_line}}"),
)

0 comments on commit fc486f2

Please sign in to comment.