Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New lint: pub trait is no longer object-safe #635

Closed
Tracked by #5
obi1kenobi opened this issue Jan 13, 2024 · 1 comment
Closed
Tracked by #5

New lint: pub trait is no longer object-safe #635

obi1kenobi opened this issue Jan 13, 2024 · 1 comment
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.

Comments

@obi1kenobi
Copy link
Owner

obi1kenobi commented Jan 13, 2024

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 the object_safe field instead of the unsafe 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#320

@obi1kenobi obi1kenobi changed the title trait is no longer object safe New lint: pub trait is no longer object-safe Jan 13, 2024
@obi1kenobi obi1kenobi added 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. labels Jan 13, 2024
@obi1kenobi
Copy link
Owner Author

Added in #659. Only beta and nightly Rust expose this data, so this feature was manually tested and its tests will be merged when all supported Rust versions expose object-safety: #661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

1 participant