diff options
| author | Alex Macleod <alex@macleod.io> | 2022-10-23 13:45:26 +0000 |
|---|---|---|
| committer | Alex Macleod <alex@macleod.io> | 2022-10-23 14:06:51 +0000 |
| commit | ff893366c1ac355822aa644c0ed43930eb605fb4 (patch) | |
| tree | df664a5bad0970146eaf1f97b75b2db2e09ebf1c /src | |
| parent | 4f142aa1058f14f153f8bfd2d82f04ddb9982388 (diff) | |
| download | rust-ff893366c1ac355822aa644c0ed43930eb605fb4.tar.gz rust-ff893366c1ac355822aa644c0ed43930eb605fb4.zip | |
Mark `let_underscore_drop` as uplifted
Diffstat (limited to 'src')
| -rw-r--r-- | src/docs.rs | 1 | ||||
| -rw-r--r-- | src/docs/let_underscore_drop.txt | 29 |
2 files changed, 0 insertions, 30 deletions
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 _ = <expr>` -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 |
