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

Unused import Clippy warnings despite being used in a server function #3449

Open
matous-volf opened this issue Dec 24, 2024 · 1 comment
Open

Comments

@matous-volf
Copy link

matous-volf commented Dec 24, 2024

Problem

Clippy emits warnings about unused imports, even though they are in fact used and required for a successful build. This happens when the code using the import is inside a Dioxus server function.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Run
dx new dioxus-unused-import
  • bare-bones
  • fullstack: true
  • router: true
  • Tailwind CSS: true
  • platform: web
  1. Run
cargo add dotenvy
  1. Import dotenvy::dotenv and use it inside a Dioxus server function (the auto-generated one in this case):
use dotenvy::dotenv;

#[server(EchoServer)]
async fn echo_server(input: String) -> Result<String, ServerFnError> {
    let _ = dotenv();
    Ok(input)
}
  1. Run
cargo clippy
  1. Observe the warning:
warning: unused import: `dotenvy::dotenv`
 --> src/main.rs:2:5
  |
2 | use dotenvy::dotenv;
  |     ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

I've done this in a reproduction repo. The warnings get emited for many more imports than just dotenv, e.g. in this repo.

Removing #[server(EchoServer)] fixes the warning, but of course breaks the functionality. This may be a Clippy issue – I don't have the insight into the macro to judge.

Expected behavior

The warning should not be emited, as the import is used.

Environment:

  • Dioxus version: 0.6.1
  • Rust version: 1.83.0
  • OS info: Docker rust:1.83-bookworm image
  • App platform: web
@ryo33
Copy link
Contributor

ryo33 commented Dec 25, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants