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: existing trait method is no longer unsafe #606

Closed
Tracked by #5
obi1kenobi opened this issue Dec 11, 2023 · 1 comment
Closed
Tracked by #5

New lint: existing trait method is no longer unsafe #606

obi1kenobi opened this issue Dec 11, 2023 · 1 comment
Labels
A-lint Area: new or existing lint 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 Dec 11, 2023

Major breaking change because existing impls of that trait must remove the unsafe from that method as well.

Example: (playground)

trait Example {
    fn method();
}

struct MyStruct;

impl Example for MyStruct {
    unsafe fn method() {}
}

This errors out:

error[E0053]: method `method` has an incompatible type for trait
 --> src/lib.rs:8:5
  |
8 |     unsafe fn method() {}
  |     ^^^^^^^^^^^^^^^^^^ expected normal fn, found unsafe fn
  |
note: type in trait
 --> src/lib.rs:2:5
  |
2 |     fn method();
  |     ^^^^^^^^^^^^
  = note: expected signature `fn()`
             found signature `unsafe fn()`

For more information about this error, try `rustc --explain E0053`.

Going in the opposite direction is breaking too: #605

@obi1kenobi obi1kenobi changed the title trait method is no longer unsafe New lint: existing trait method is no longer unsafe Dec 11, 2023
@obi1kenobi obi1kenobi added A-lint Area: new or existing lint 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 Dec 11, 2023
@obi1kenobi
Copy link
Owner Author

Implemented in #612.

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 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