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

should_implement_trait does not consider function safety. #5413

Closed
human-0 opened this issue Apr 4, 2020 · 1 comment · Fixed by #5437
Closed

should_implement_trait does not consider function safety. #5413

human-0 opened this issue Apr 4, 2020 · 1 comment · Fixed by #5437
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@human-0
Copy link

human-0 commented Apr 4, 2020

Consider this:

enum Foo(u8) { // Probably struct as well
    _1, _2, ...
}

impl Foo {
    unsafe fn add(self, rhs: u8) -> Foo { ... }
}

This triggers should_implement_trait, which a false positive, as Add requires a normal function, not an unsafe one.

cargo clippy -V:

clippy 0.0.212 (4ee12063 2020-02-01)
@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Apr 4, 2020
@flip1995
Copy link
Member

flip1995 commented Apr 4, 2020

related #4290

rabisg0 added a commit to rabisg0/rust-clippy that referenced this issue Apr 8, 2020
When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes rust-lang#5413, rust-lang#4290
rabisg0 added a commit to rabisg0/rust-clippy that referenced this issue Apr 8, 2020
When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes rust-lang#5413, rust-lang#4290
bors added a commit that referenced this issue Apr 8, 2020
Check fn header along with decl when suggesting to implement trait

When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes #5413, #4290

changelog: check fn header along with decl for should_implement_trait
@bors bors closed this as completed in c2e5534 Apr 8, 2020
rokob pushed a commit to rokob/rust-clippy that referenced this issue Apr 17, 2020
When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes rust-lang#5413, rust-lang#4290
rokob pushed a commit to rokob/rust-clippy that referenced this issue Apr 17, 2020
When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes rust-lang#5413, rust-lang#4290
rokob pushed a commit to rokob/rust-clippy that referenced this issue Apr 17, 2020
When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes rust-lang#5413, rust-lang#4290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants