New lint: pub trait is no longer object-safe #635
Labels
A-lint
Area: new or existing lint
C-enhancement
Category: raise the bar on expectations
E-help-wanted
Call for participation: Help is requested to fix this issue.
E-mentor
Call for participation: Mentorship is available for this issue.
Object-safety refers to whether a trait can be used as a
&dyn Trait
. It is part of the public API of public traits: the loss of object-safety would cause compilation errors in any code that uses it as&dyn Trait
.At the same time, object-safety is not immediately obvious — it's not explicitly written down in the source code of the trait — so it's easy to miss.
We need a lint that can catch cases where a public API object-safe trait stopped being object-safe. The lint query itself is going to look similar to lints about traits becoming
unsafe
, but checking theobject_safe
field instead of theunsafe
field.At the moment, the
object_safe
field needs to be added to the schema for traits. This is a very easy first issue: obi1kenobi/trustfall-rustdoc-adapter#320The text was updated successfully, but these errors were encountered: