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

let-binding has unit value fix breaks code #111247

Closed
Eagle941 opened this issue May 5, 2023 · 5 comments
Closed

let-binding has unit value fix breaks code #111247

Eagle941 opened this issue May 5, 2023 · 5 comments
Labels
C-bug Category: This is a bug.

Comments

@Eagle941
Copy link

Eagle941 commented May 5, 2023

This is the code:

pub struct AnyId<T: ?Sized> {
   metadata: <T as Pointee>::Metadata,
}

pub struct AnyStore {}

impl AnyStore {
   pub fn push<T: 'static>(value: T) -> AnyId<T> {
      let metadata = std::ptr::metadata(&value);
      AnyId {
	   metadata,
      }
   }
}

I have got this warning:

warning: this let-binding has unit value
  --> dyn_utils\src\any_store.rs:97:3
   |
97 |         let metadata = std::ptr::metadata(&value);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `std::ptr::metadata(&value);`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
   = note: `#[warn(clippy::let_unit_value)]` on by default

I tried this command:

cargo clippy --fix --lib -p dyn_utils

This happened:

The following errors were reported:
error[E0425]: cannot find value `metadata` in this scope
   --> dyn_utils\src\any_store.rs:111:4
    |
111 |             metadata,
    |             ^^^^^^^^ not found in this scope
    |
help: consider importing one of these items
    |
1   | use core::ptr::metadata;
    |
1   | use std::fs::metadata;
    |
1   | use std::ptr::metadata;
    |

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
Original diagnostics will follow.

warning: this let-binding has unit value
  --> dyn_utils\src\any_store.rs:97:3
   |
97 |         let metadata = std::ptr::metadata(&value);
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `std::ptr::metadata(&value);`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
   = note: `#[warn(clippy::let_unit_value)]` on by default

warning: `dyn_utils` (lib) generated 1 warning (run `cargo clippy --fix --lib -p dyn_utils` to apply 1 suggestion)
    Finished dev [unoptimized + debuginfo] target(s) in 0.48s

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (f3126500f 2023-02-02)
binary: rustc
commit-hash: f3126500f25114ba4e0ac3e76694dd45a22de56d
commit-date: 2023-02-02
host: x86_64-pc-windows-msvc
release: 1.69.0-nightly
LLVM version: 15.0.7
@Eagle941 Eagle941 added the C-bug Category: This is a bug. label May 5, 2023
@workingjubilee workingjubilee added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels May 5, 2023
@compiler-errors
Copy link
Member

compiler-errors commented May 5, 2023

This is a clippy lint bug, so not sure if this should be tagged with diagnostics tags, @workingjubilee. Shouldn't we just move this issue to that repo?

@workingjubilee
Copy link
Member

Oh, durr.

@workingjubilee
Copy link
Member

I don't have the power to move issues to clippy, unforch.

@workingjubilee workingjubilee removed A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels May 5, 2023
@Eagle941
Copy link
Author

Eagle941 commented May 5, 2023

This is a clippy lint bug, so not sure if this should be tagged with diagnostics tags, @workingjubilee. Shouldn't we just move this issue to that repo?

I was wondering that but cargo output recommended to open an issue here

@compiler-errors
Copy link
Member

As of rust-lang/cargo#11882, cargo should now suggest the correct repository to report this bug. @Eagle941, thanks for the report but please re-open this as a clippy issue 😃 (and perhaps rustup update your nightly toolchain?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants