From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/clippy/tests/ui/drop_non_drop.rs | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/tools/clippy/tests/ui/drop_non_drop.rs (limited to 'src/tools/clippy/tests/ui/drop_non_drop.rs') diff --git a/src/tools/clippy/tests/ui/drop_non_drop.rs b/src/tools/clippy/tests/ui/drop_non_drop.rs new file mode 100644 index 000000000..5a0ebde82 --- /dev/null +++ b/src/tools/clippy/tests/ui/drop_non_drop.rs @@ -0,0 +1,40 @@ +#![warn(clippy::drop_non_drop)] + +use core::mem::drop; + +fn make_result(t: T) -> Result { + Ok(t) +} + +#[must_use] +fn must_use(t: T) -> T { + t +} + +fn drop_generic(t: T) { + // Don't lint + drop(t) +} + +fn main() { + struct Foo; + // Lint + drop(Foo); + // Don't lint + drop(make_result(Foo)); + // Don't lint + drop(must_use(Foo)); + + struct Bar; + impl Drop for Bar { + fn drop(&mut self) {} + } + // Don't lint + drop(Bar); + + struct Baz(T); + // Lint + drop(Baz(Foo)); + // Don't lint + drop(Baz(Bar)); +} -- cgit v1.2.3