Skip to content

Commit 0b8ffac

Browse files
matthiaskrgrcalebcartwright
authored andcommitted
fix a bunch of the other clippy warnings that look interesting
1 parent c493ee4 commit 0b8ffac

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/comment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl CodeBlockAttribute {
405405
/// attributes are valid rust attributes
406406
/// See <https://doc.rust-lang.org/rustdoc/print.html#attributes>
407407
fn new(attributes: &str) -> CodeBlockAttribute {
408-
for attribute in attributes.split(",") {
408+
for attribute in attributes.split(',') {
409409
match attribute.trim() {
410410
"" | "rust" | "should_panic" | "no_run" | "edition2015" | "edition2018"
411411
| "edition2021" => (),
@@ -1384,7 +1384,7 @@ impl<'a> Iterator for LineClasses<'a> {
13841384
None => unreachable!(),
13851385
};
13861386

1387-
while let Some((kind, c)) = self.base.next() {
1387+
for (kind, c) in self.base.by_ref() {
13881388
// needed to set the kind of the ending character on the last line
13891389
self.kind = kind;
13901390
if c == '\n' {

src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,11 +1207,11 @@ fn rewrite_int_lit(context: &RewriteContext<'_>, lit: &ast::Lit, shape: Shape) -
12071207
let span = lit.span;
12081208
let symbol = lit.token.symbol.as_str();
12091209

1210-
if symbol.starts_with("0x") {
1210+
if let Some(symbol_stripped) = symbol.strip_prefix("0x") {
12111211
let hex_lit = match context.config.hex_literal_case() {
12121212
HexLiteralCase::Preserve => None,
1213-
HexLiteralCase::Upper => Some(symbol[2..].to_ascii_uppercase()),
1214-
HexLiteralCase::Lower => Some(symbol[2..].to_ascii_lowercase()),
1213+
HexLiteralCase::Upper => Some(symbol_stripped.to_ascii_uppercase()),
1214+
HexLiteralCase::Lower => Some(symbol_stripped.to_ascii_lowercase()),
12151215
};
12161216
if let Some(hex_lit) = hex_lit {
12171217
return wrap_str(

src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn collect_beginning_verts(
168168
.map(|a| {
169169
context
170170
.snippet(a.pat.span)
171-
.starts_with("|")
171+
.starts_with('|')
172172
.then(|| a.pat.span().lo())
173173
})
174174
.collect()

src/modules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
197197
/// Visit modules from AST.
198198
fn visit_mod_from_ast(
199199
&mut self,
200-
items: &'ast Vec<rustc_ast::ptr::P<ast::Item>>,
200+
items: &'ast [rustc_ast::ptr::P<ast::Item>],
201201
) -> Result<(), ModuleResolutionError> {
202202
for item in items {
203203
if is_cfg_if(item) {

src/patterns.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,11 @@ fn rewrite_tuple_pat(
456456
context: &RewriteContext<'_>,
457457
shape: Shape,
458458
) -> Option<String> {
459-
let mut pat_vec: Vec<_> = pats.iter().map(|x| TuplePatField::Pat(x)).collect();
460-
461-
if pat_vec.is_empty() {
459+
if pats.is_empty() {
462460
return Some(format!("{}()", path_str.unwrap_or_default()));
463461
}
462+
let mut pat_vec: Vec<_> = pats.iter().map(TuplePatField::Pat).collect();
463+
464464
let wildcard_suffix_len = count_wildcard_suffix_len(context, &pat_vec, span, shape);
465465
let (pat_vec, span) = if context.config.condense_wildcard_suffixes() && wildcard_suffix_len >= 2
466466
{

0 commit comments

Comments
 (0)