Skip to content

Commit 8ea6790

Browse files
authored
Rollup merge of #45253 - Gankro:drop_docs, r=kennytm
Clarify how needs_drop is conservative
2 parents fb98e3e + 11775ab commit 8ea6790

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: src/libcore/mem.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,11 @@ pub fn align_of_val<T: ?Sized>(val: &T) -> usize {
429429

430430
/// Returns whether dropping values of type `T` matters.
431431
///
432-
/// This is purely an optimization hint, and may be implemented conservatively.
433-
/// For instance, always returning `true` would be a valid implementation of
434-
/// this function.
432+
/// This is purely an optimization hint, and may be implemented conservatively:
433+
/// it may return `true` for types that don't actually need to be dropped.
434+
/// As such always returning `true` would be a valid implementation of
435+
/// this function. However if this function actually returns `false`, then you
436+
/// can be certain dropping `T` has no side effect.
435437
///
436438
/// Low level implementations of things like collections, which need to manually
437439
/// drop their data, should use this function to avoid unnecessarily

0 commit comments

Comments
 (0)