Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8c99633

Browse files
committed
fix a couple of clippy lint warnings
simplify a comparison with "true" fn can_be_overflowed: remove unused lifetime fn rewrite_pairs_one_line: pass "list" by reference (it is not consumed in the function) fn span_for_token_stream: pass "token_stream" by reference since it is not consumed use tool lints for clippy suppressions
1 parent e633f2b commit 8c99633

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/lists.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ where
752752
}
753753
}
754754

755-
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
755+
#[allow(clippy::too_many_arguments)]
756756
// Creates an iterator over a list's items with associated comments.
757757
pub fn itemize_list<'a, T, I, F1, F2, F3>(
758758
snippet_provider: &'a SnippetProvider,

src/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub fn rewrite_macro_def(
429429
Some(v) => Some(v),
430430
// if the rewrite returned None because a macro could not be rewritten, then return the
431431
// original body
432-
None if *context.macro_rewrite_failure.borrow() == true => {
432+
None if *context.macro_rewrite_failure.borrow() => {
433433
Some(context.snippet(branch.body).trim().to_string())
434434
}
435435
None => None,
@@ -981,7 +981,7 @@ fn format_macro_args(
981981
) -> Option<String> {
982982
if !context.config.format_macro_matchers() {
983983
let token_stream: TokenStream = toks.into();
984-
let span = span_for_token_stream(token_stream);
984+
let span = span_for_token_stream(&token_stream);
985985
return Some(match span {
986986
Some(span) => context.snippet(span).to_owned(),
987987
None => String::new(),
@@ -991,7 +991,7 @@ fn format_macro_args(
991991
wrap_macro_args(context, &parsed_args, shape)
992992
}
993993

994-
fn span_for_token_stream(token_stream: TokenStream) -> Option<Span> {
994+
fn span_for_token_stream(token_stream: &TokenStream) -> Option<Span> {
995995
token_stream.trees().next().map(|tt| tt.span())
996996
}
997997

src/overflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ fn need_block_indent(s: &str, shape: Shape) -> bool {
690690
})
691691
}
692692

693-
fn can_be_overflowed<'a>(context: &RewriteContext, items: &[OverflowableItem]) -> bool {
693+
fn can_be_overflowed(context: &RewriteContext, items: &[OverflowableItem]) -> bool {
694694
items
695695
.last()
696696
.map_or(false, |x| x.can_be_overflowed(context, items.len()))

src/pairs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(crate) fn rewrite_all_pairs(
5454
// necessarily need one line per sub-expression, but we don't do anything
5555
// too funny wrt precedence.
5656
expr.flatten(true)
57-
.and_then(|list| rewrite_pairs_multiline(list, shape, context))
57+
.and_then(|list| rewrite_pairs_multiline(&list, shape, context))
5858
}
5959

6060
// This may return a multi-line result since we allow the last expression to go
@@ -105,7 +105,7 @@ fn rewrite_pairs_one_line<T: Rewrite>(
105105
}
106106

107107
fn rewrite_pairs_multiline<T: Rewrite>(
108-
list: PairList<T>,
108+
list: &PairList<T>,
109109
shape: Shape,
110110
context: &RewriteContext,
111111
) -> Option<String> {

src/visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
573573
self.buffer.push_str(s);
574574
}
575575

576-
#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
576+
#[allow(clippy::needless_pass_by_value)]
577577
fn push_rewrite_inner(&mut self, span: Span, rewrite: Option<String>) {
578578
if let Some(ref s) = rewrite {
579579
self.push_str(s);

0 commit comments

Comments
 (0)