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

default_constructed_unit_structs sugg causes error #12654

Open
matthiaskrgr opened this issue Apr 9, 2024 · 0 comments
Open

default_constructed_unit_structs sugg causes error #12654

matthiaskrgr opened this issue Apr 9, 2024 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@matthiaskrgr
Copy link
Member

Summary

.

Reproducer

I tried this code:

struct G;

impl PartialEq<B> for G {
	fn eq(&self, _: &B) -> bool {
		true
	}
}

#[derive(Debug, Default)]
struct B;


fn main() {
    let _ = G::eq(&G, dbg!(&<_>::default()));
}

Instead, this happened:

warning: use of `default` to create a unit struct
  --> ./tests/ui/lint/non-local-defs/generics.rs:14:31
   |
14 |     let _ = G::eq(&G, dbg!(&<_>::default()));
   |                               ^^^^^^^^^^^^ help: remove this call to `default`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#default_constructed_unit_structs
   = note: requested on the command line with `-W clippy::default-constructed-unit-structs`

This does not work lol

error: expected one of `>` or `as`, found `<eof>`
   --> src/main.rs:14:30
    |
14  |     let _ = G::eq(&G, dbg!(&<_));
    |                              ^ expected one of `>` or `as`
    |

Version

rustc 1.79.0-nightly (ab5bda1aa 2024-04-08)
binary: rustc
commit-hash: ab5bda1aa70f707014e2e691e43bc37a8819252a
commit-date: 2024-04-08
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

Additional Labels

No response

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Apr 9, 2024
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-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

1 participant