about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-27 00:38:23 +0000
committerbors <bors@rust-lang.org>2020-09-27 00:38:23 +0000
commit949b834067bdfbde6080358fae29845d86e2db01 (patch)
tree3a7914bc1b0064c7ae59dad6ebe48358c5be9900
parentea079eb8a4ad3b7ccdfd102bbbd722bf0a203378 (diff)
parent00e641b91417a0b4489544406f60a1e2babe7c88 (diff)
downloadrust-949b834067bdfbde6080358fae29845d86e2db01.tar.gz
rust-949b834067bdfbde6080358fae29845d86e2db01.zip
Auto merge of #6090 - Fishrock123:rc_buffer-formatting-caveats, r=yaahc
lints: clarify rc_buffer and add caveats

This didn't display some types properly in the docs due the lack of code formatting.

Also, refs for the caveat:
https://github.com/rust-lang/rust-clippy/pull/6044#issuecomment-699559082
https://github.com/http-rs/surf/pull/242

Fwiw I can't get `cargo test` to run, even on nightly. I get:
```
error[E0463]: can't find crate for `rustc_ast`
```

*Please keep the line below*
changelog: none, nightly
-rw-r--r--clippy_lints/src/types.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs
index a29a199b8c3..17d950169fd 100644
--- a/clippy_lints/src/types.rs
+++ b/clippy_lints/src/types.rs
@@ -216,18 +216,19 @@ declare_clippy_lint! {
 }
 
 declare_clippy_lint! {
-    /// **What it does:** Checks for Rc<T> and Arc<T> when T is a mutable buffer type such as String or Vec
+    /// **What it does:** Checks for `Rc<T>` and `Arc<T>` when `T` is a mutable buffer type such as `String` or `Vec`.
     ///
-    /// **Why is this bad?** Expressions such as Rc<String> have no advantage over Rc<str>, since
-    /// it is larger and involves an extra level of indirection, and doesn't implement Borrow<str>.
+    /// **Why is this bad?** Expressions such as `Rc<String>` usually have no advantage over `Rc<str>`, since
+    /// it is larger and involves an extra level of indirection, and doesn't implement `Borrow<str>`.
     ///
-    /// While mutating a buffer type would still be possible with Rc::get_mut(), it only
-    /// works if there are no additional references yet, which defeats the purpose of
+    /// While mutating a buffer type would still be possible with `Rc::get_mut()`, it only
+    /// works if there are no additional references yet, which usually defeats the purpose of
     /// enclosing it in a shared ownership type. Instead, additionally wrapping the inner
-    /// type with an interior mutable container (such as RefCell or Mutex) would normally
+    /// type with an interior mutable container (such as `RefCell` or `Mutex`) would normally
     /// be used.
     ///
-    /// **Known problems:** None.
+    /// **Known problems:** This pattern can be desirable to avoid the overhead of a `RefCell` or `Mutex` for
+    /// cases where mutation only happens before there are any additional references.
     ///
     /// **Example:**
     /// ```rust,ignore