Skip to content

expected a type, found an import warning false positive of "disallowed-types" #14767

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

Closed
ldm0 opened this issue May 9, 2025 · 4 comments · Fixed by #14772
Closed

expected a type, found an import warning false positive of "disallowed-types" #14767

ldm0 opened this issue May 9, 2025 · 4 comments · Fixed by #14772
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@ldm0
Copy link
Contributor

ldm0 commented May 9, 2025

Summary

"disallowed-types"'s false positive

Lint Name

disallowed-types

Reproducer

Minimal reproduction: https://github.com/ldm0/rust_test2

cargo clippy -p foo

I saw this happen:

warning: expected a type, found an import
 --> /Users/ldm0/repo/tmp/rust_test3/clippy.toml:2:5
  |
2 |     { path = "foo::Fooo", reason = "Noooooooooo" },
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: `foo` (lib) generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s

I expected to see no warning emitted.

Version

rustc 1.88.0-nightly (cb31a009e 2025-04-27)
binary: rustc
commit-hash: cb31a009e3e735ab08613cec2d8a5a754e65596f
commit-date: 2025-04-27
host: aarch64-apple-darwin
release: 1.88.0-nightly
LLVM version: 20.1.2

Additional Labels

No response

@ldm0 ldm0 added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels May 9, 2025
ldm0 added a commit to ldm0/rust_test2 that referenced this issue May 9, 2025
@samueltardieu
Copy link
Contributor

Why would you put something in disallowed-types in the first place if you don't want do disallow it?

@ldm0
Copy link
Contributor Author

ldm0 commented May 9, 2025

Why would you put something in disallowed-types in the first place if you don't want do disallow it?

In reality, we have a large workspace where foo is a library in it. And we don't want other crates in this workspace to depend on some types of foo. So we put them in disallowed-types. The problem is that foo itself emits strange warning(described in this issue).

@smoelius
Copy link
Contributor

smoelius commented May 9, 2025

@ldm0 Suppose adding #![allow(clippy::disallowed_types)] to foo/src/lib.rs made the warning go away. (It currently doesn't, but if it did...) Do you think that would solve the problem for your actual workspace?

@Alexendoo
Copy link
Member

The issue is that it's not resolving through the re-export, that can be fixed directly

For the meantime path = "foo::fooo::Fooo should work

github-merge-queue bot pushed a commit that referenced this issue May 10, 2025
Fixes #14767

A long standing issue revealed by
#14397

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
4 participants