Skip to content

Commit 1335311

Browse files
committed
Add known problem to needless_borrow lint
The `needless_borrow` lint is temporarily disabled because of some false positives it causes in combination with the `derive` macro. However the documentation does not explain these issues, but instead lists `Known problems: None`. To make it clear why this lint is currently not enabled, a description of the false positives caused by this lint has been added to the `Known problems` section.
1 parent fde487c commit 1335311

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

clippy_lints/src/needless_borrow.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,23 @@ use crate::utils::{in_macro, snippet_opt, span_lint_and_then};
1616
/// **Why is this bad?** Suggests that the receiver of the expression borrows
1717
/// the expression.
1818
///
19-
/// **Known problems:** None.
20-
///
2119
/// **Example:**
2220
/// ```rust
2321
/// let x: &i32 = &&&&&&5;
2422
/// ```
23+
///
24+
/// **Known problems:** This will cause false positives in code generated by `derive`.
25+
/// For instance in the following snippet:
26+
/// ```rust
27+
/// #[derive(Debug)]
28+
/// pub enum Error {
29+
/// Type(
30+
/// &'static str,
31+
/// ),
32+
/// }
33+
/// ```
34+
/// A warning will be emitted that `&'static str` should be replaced with `&'static str`,
35+
/// however there is nothing that can or should be done to fix this.
2536
declare_clippy_lint! {
2637
pub NEEDLESS_BORROW,
2738
nursery,

0 commit comments

Comments
 (0)