Skip to content
Discussion options

You must be logged in to vote

You can't. Clippy has no versioned path form like foo@1::…. Paths are plain crate::module::Item.

Use both layouts and set allow-invalid = true:

disallowed-methods = [
    { path = "foo::Bar::baz", allow-invalid = true },
    { path = "foo::bar::Bar::baz", allow-invalid = true },
]

Clippy runs per crate. A package that only depends on foo v1 never sees the v2 path, so it warns unless you allow invalid. Same the other way for v2-only packages. The ban still applies when the path does resolve.

Related: #17006

Pitfall: Cargo renames do not help. Clippy matches the crate's real name, not the alias.

Version pinning in config would need a Clippy feature request.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@asasine
Comment options

Answer selected by asasine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants