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.
This commit is contained in:
@@ -107,6 +107,7 @@ pub struct EnumVariantNames {
|
||||
}
|
||||
|
||||
impl EnumVariantNames {
|
||||
#[must_use]
|
||||
pub fn new(threshold: u64) -> Self {
|
||||
Self {
|
||||
modules: Vec::new(),
|
||||
@@ -123,6 +124,7 @@ impl_lint_pass!(EnumVariantNames => [
|
||||
]);
|
||||
|
||||
/// Returns the number of chars that match from the start
|
||||
#[must_use]
|
||||
fn partial_match(pre: &str, name: &str) -> usize {
|
||||
let mut name_iter = name.chars();
|
||||
let _ = name_iter.next_back(); // make sure the name is never fully matched
|
||||
@@ -130,6 +132,7 @@ fn partial_match(pre: &str, name: &str) -> usize {
|
||||
}
|
||||
|
||||
/// Returns the number of chars that match from the end
|
||||
#[must_use]
|
||||
fn partial_rmatch(post: &str, name: &str) -> usize {
|
||||
let mut name_iter = name.chars();
|
||||
let _ = name_iter.next(); // make sure the name is never fully matched
|
||||
@@ -211,6 +214,7 @@ fn check_variant(
|
||||
);
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn to_camel_case(item_name: &str) -> String {
|
||||
let mut s = String::new();
|
||||
let mut up = true;
|
||||
|
||||
Reference in New Issue
Block a user