From ff893366c1ac355822aa644c0ed43930eb605fb4 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Sun, 23 Oct 2022 13:45:26 +0000 Subject: Mark `let_underscore_drop` as uplifted --- src/docs.rs | 1 - src/docs/let_underscore_drop.txt | 29 ----------------------------- 2 files changed, 30 deletions(-) delete mode 100644 src/docs/let_underscore_drop.txt (limited to 'src') diff --git a/src/docs.rs b/src/docs.rs index c033ad294a3..e9aa6e88097 100644 --- a/src/docs.rs +++ b/src/docs.rs @@ -247,7 +247,6 @@ docs! { "len_without_is_empty", "len_zero", "let_and_return", - "let_underscore_drop", "let_underscore_lock", "let_underscore_must_use", "let_unit_value", diff --git a/src/docs/let_underscore_drop.txt b/src/docs/let_underscore_drop.txt deleted file mode 100644 index 29ce9bf50ce..00000000000 --- a/src/docs/let_underscore_drop.txt +++ /dev/null @@ -1,29 +0,0 @@ -### What it does -Checks for `let _ = ` -where expr has a type that implements `Drop` - -### Why is this bad? -This statement immediately drops the initializer -expression instead of extending its lifetime to the end of the scope, which -is often not intended. To extend the expression's lifetime to the end of the -scope, use an underscore-prefixed name instead (i.e. _var). If you want to -explicitly drop the expression, `std::mem::drop` conveys your intention -better and is less error-prone. - -### Example -``` -{ - let _ = DroppableItem; - // ^ dropped here - /* more code */ -} -``` - -Use instead: -``` -{ - let _droppable = DroppableItem; - /* more code */ - // dropped at end of scope -} -``` \ No newline at end of file -- cgit 1.4.1-3-g733a5