Skip to content

Commit bc4c3b6

Browse files
committed
Add more descriptive details
1 parent 2da7f08 commit bc4c3b6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clippy_lints/src/drop_bounds.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ use rustc::{declare_tool_lint, lint_array};
1212
/// `Drop::drop`, and that function is by fiat not callable in user code.
1313
/// So there is really no use case for using `Drop` in trait bounds.
1414
///
15+
/// The most likely use case of a drop bound is to distinguish between types
16+
/// that have destructors and types that don't. Combined with specialization,
17+
/// a naive coder would write an implementation that assumed a type could be
18+
/// trivially dropped, then write a specialization for `T: Drop` that actually
19+
/// calls the destructor. Except that doing so is not correct; String, for
20+
/// example, doesn't actually implement Drop, but because String contains a
21+
/// Vec, assuming it can be trivially dropped will leak memory.
22+
///
1523
/// **Known problems:** None.
1624
///
1725
/// **Example:**

0 commit comments

Comments
 (0)