Filipe Rodrigues
Filipe Rodrigues

Reputation: 2177

How to use `clippy::disallowed_method` with methods inside the same crate

I have some functions defined in my crate that I want to disallow the use of inside of the same, using clippy::disallowed_methods.

For example:

fn f() { ... }

fn g() {
    f(); // Warning
}

I've tried the following clippy.toml

disallowed-methods = [
  "crate::f"
]

But no warning shows up when I run cargo clippy.

I've also tried f, my_crate::f and ::my_crate::f, where my_crate is the name of the crate both functions are defined in, but none of them work.

I've tried it with other methods in external crates, such as std::vec::Vec::new and a warning successfully shows up.

Is there any way to make disallowed_methods work without moving the methods to another crate?

Upvotes: 2

Views: 520

Answers (0)

Related Questions