From cc622608db7318b1c0fe3ccd541558436c7c6c4c Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Wed, 18 Sep 2019 08:37:41 +0200 Subject: new lints around `#[must_use]` fns `must_use_unit` lints unit-returning functions with a `#[must_use]` attribute, suggesting to remove it. `double_must_use` lints functions with a plain `#[must_use]` attribute, but which return a type which is already `#[must_use]`, so the attribute has no benefit. `must_use_candidate` is a pedantic lint that lints functions and methods that return some non-unit type that is not already `#[must_use]` and suggests to add the annotation. --- src/lintlist/mod.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs index 28f212fb2b2..66ee41402ea 100644 --- a/src/lintlist/mod.rs +++ b/src/lintlist/mod.rs @@ -6,7 +6,7 @@ pub use lint::Lint; pub use lint::LINT_LEVELS; // begin lint list, do not remove this comment, it’s used in `update_lints` -pub const ALL_LINTS: [Lint; 321] = [ +pub const ALL_LINTS: [Lint; 324] = [ Lint { name: "absurd_extreme_comparisons", group: "correctness", @@ -350,6 +350,13 @@ pub const ALL_LINTS: [Lint; 321] = [ deprecation: None, module: "double_comparison", }, + Lint { + name: "double_must_use", + group: "style", + desc: "`#[must_use]` attribute on a `#[must_use]`-returning function / method", + deprecation: None, + module: "functions", + }, Lint { name: "double_neg", group: "style", @@ -1155,6 +1162,20 @@ pub const ALL_LINTS: [Lint; 321] = [ deprecation: None, module: "inherent_impl", }, + Lint { + name: "must_use_candidate", + group: "pedantic", + desc: "function or method that could take a `#[must_use]` attribute", + deprecation: None, + module: "functions", + }, + Lint { + name: "must_use_unit", + group: "style", + desc: "`#[must_use]` attribute on a unit-returning function / method", + deprecation: None, + module: "functions", + }, Lint { name: "mut_from_ref", group: "correctness", -- cgit 1.4.1-3-g733a5