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

infinite loop error: cargo clippy --all-features -- -D warnings #11247

Closed
dierbei opened this issue Jul 28, 2023 · 3 comments
Closed

infinite loop error: cargo clippy --all-features -- -D warnings #11247

dierbei opened this issue Jul 28, 2023 · 3 comments
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 I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@dierbei
Copy link

dierbei commented Jul 28, 2023

Summary

My code is like this:

async fn process_config(sandbox: &mut KuasarSandbox<QemuVM>) -> Result<()> {
    if let Some(resources) = get_resources(&sandbox.data) {
        if resources.cpu_period > 0 && resources.cpu_quota > 0 {
            // get ceil of cpus if it is not integer
            let base = (resources.cpu_quota as f64 / resources.cpu_period as f64).ceil();
            sandbox.vm.config.smp.cpus = base as u32;
            sandbox.vm.config.smp.max_cpus = base as u32;
        }
        if resources.memory_limit_in_bytes > 0 {
            sandbox.vm.config.memory.size = format!(
                "{}M",
                ((resources.memory_limit_in_bytes) as u64 / bytefmt::MIB) as u32
            );
        }
        // TODO add other resource limits to vm
    }
    Ok(())
}

I'm running into a problem when I try to run the command: cargo clippy --all-features -- -D warnings

error: this argument is a mutable reference, but not used mutably
  --> src/qemu/hooks.rs:57:34
   |
57 | async fn process_config(sandbox: &mut KuasarSandbox<QemuVM>) -> Result<()> {
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&KuasarSandbox<QemuVM>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
   = note: `-D clippy::needless-pass-by-ref-mut` implied by `-D warnings`

After modifying according to the prompt:

     Checking vmm-sandboxer v0.1.0 (/root/dierbei/kuasar/vmm/sandbox)
error[E0594]: cannot assign to `sandbox.vm.config.smp.cpus`, which is behind a `&` reference
  --> src/qemu/hooks.rs:62:13
   |
62 |             sandbox.vm.config.smp.cpus = base as u32;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `sandbox` is a `&` reference, so the data it refers to cannot be written
   |
help: consider specifying this binding's type
   |
57 | async fn process_config(sandbox: &mut sandbox::KuasarSandbox<qemu::QemuVM>: &KuasarSandbox<QemuVM>) -> Result<()> {
   |                                +++++++++++++++++++++++++++++++++++++++++++

error[E0594]: cannot assign to `sandbox.vm.config.smp.max_cpus`, which is behind a `&` reference
  --> src/qemu/hooks.rs:63:13
   |
63 |             sandbox.vm.config.smp.max_cpus = base as u32;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `sandbox` is a `&` reference, so the data it refers to cannot be written
   |
help: consider specifying this binding's type
   |
57 | async fn process_config(sandbox: &mut sandbox::KuasarSandbox<qemu::QemuVM>: &KuasarSandbox<QemuVM>) -> Result<()> {
   |                                +++++++++++++++++++++++++++++++++++++++++++

error[E0594]: cannot assign to `sandbox.vm.config.memory.size`, which is behind a `&` reference
  --> src/qemu/hooks.rs:66:13
   |
66 |             sandbox.vm.config.memory.size = format!(
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `sandbox` is a `&` reference, so the data it refers to cannot be written

Reproducer

No response

Version

rustc 1.73.0-nightly (500647fd8 2023-07-27)
binary: rustc
commit-hash: 500647fd8138cc09e87edb08d62f81654fbf6ef8
commit-date: 2023-07-27
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Additional Labels

No response

@dierbei dierbei added the C-bug Category: Clippy is not doing the correct thing label Jul 28, 2023
@y21
Copy link
Member

y21 commented Jul 28, 2023

Looks like the same issue as #11179 (comment), which was fixed in #11184.
The fix should be in nightly when the next sync happens (in 3 or 4 days if I'm not mistaken)

@KisaragiEffective
Copy link
Contributor

@rustbot label +I-false-positive,+I-suggestion-causes-error

@rustbot rustbot added I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Jul 29, 2023
@GuillaumeGomez
Copy link
Member

If it's fixed, can it be closed then?

@dierbei dierbei closed this as completed Oct 7, 2023
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 I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

No branches or pull requests

5 participants