Skip to content

Commit 80d96df

Browse files
committed
lint-docs: apply considerable clippy suggestions
Signed-off-by: onur-ozkan <[email protected]>
1 parent 5aa3fbc commit 80d96df

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Diff for: src/tools/lint-docs/src/groups.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ impl<'a> LintExtractor<'a> {
121121
};
122122
to_link.extend(group_lints);
123123
let brackets: Vec<_> = group_lints.iter().map(|l| format!("[{}]", l)).collect();
124-
write!(result, "| {} | {} | {} |\n", group_name, description, brackets.join(", "))
124+
writeln!(result, "| {} | {} | {} |", group_name, description, brackets.join(", "))
125125
.unwrap();
126126
}
127127
result.push('\n');
128128
result.push_str("[warn-by-default]: listing/warn-by-default.md\n");
129129
for lint_name in to_link {
130-
let lint_def = match lints.iter().find(|l| l.name == lint_name.replace("-", "_")) {
130+
let lint_def = match lints.iter().find(|l| l.name == lint_name.replace('-', "_")) {
131131
Some(def) => def,
132132
None => {
133133
let msg = format!(
@@ -144,9 +144,9 @@ impl<'a> LintExtractor<'a> {
144144
}
145145
}
146146
};
147-
write!(
147+
writeln!(
148148
result,
149-
"[{}]: listing/{}#{}\n",
149+
"[{}]: listing/{}#{}",
150150
lint_name,
151151
lint_def.level.doc_filename(),
152152
lint_name

Diff for: src/tools/lint-docs/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ impl Lint {
8484
for &expected in &["### Example", "### Explanation", "{{produces}}"] {
8585
if expected == "{{produces}}" && self.is_ignored() {
8686
if self.doc_contains("{{produces}}") {
87-
return Err(format!(
88-
"the lint example has `ignore`, but also contains the {{{{produces}}}} marker\n\
87+
return Err(
88+
"the lint example has `ignore`, but also contains the {{produces}} marker\n\
8989
\n\
9090
The documentation generator cannot generate the example output when the \
9191
example is ignored.\n\
@@ -111,7 +111,7 @@ impl Lint {
111111
Replacing the output with the text of the example you \
112112
compiled manually yourself.\n\
113113
"
114-
).into());
114+
.into());
115115
}
116116
continue;
117117
}
@@ -519,11 +519,11 @@ impl<'a> LintExtractor<'a> {
519519
let mut these_lints: Vec<_> = lints.iter().filter(|lint| lint.level == level).collect();
520520
these_lints.sort_unstable_by_key(|lint| &lint.name);
521521
for lint in &these_lints {
522-
write!(result, "* [`{}`](#{})\n", lint.name, lint.name.replace("_", "-")).unwrap();
522+
writeln!(result, "* [`{}`](#{})", lint.name, lint.name.replace('_', "-")).unwrap();
523523
}
524524
result.push('\n');
525525
for lint in &these_lints {
526-
write!(result, "## {}\n\n", lint.name.replace("_", "-")).unwrap();
526+
write!(result, "## {}\n\n", lint.name.replace('_', "-")).unwrap();
527527
for line in &lint.doc {
528528
result.push_str(line);
529529
result.push('\n');
@@ -583,7 +583,7 @@ fn add_rename_redirect(level: Level, output: &mut String) {
583583
let filename = level.doc_filename().replace(".md", ".html");
584584
output.push_str(RENAME_START);
585585
for (from, to) in *names {
586-
write!(output, " \"#{from}\": \"{filename}#{to}\",\n").unwrap();
586+
writeln!(output, " \"#{from}\": \"{filename}#{to}\",").unwrap();
587587
}
588588
output.push_str(RENAME_END);
589589
}

0 commit comments

Comments
 (0)