Shared: Clippy fixes

Use clearer methods where appropriate.
This commit is contained in:
Harry Maclean
2023-04-05 16:37:51 +08:00
parent 6a8d417588
commit 2107533822
2 changed files with 7 additions and 7 deletions

View File

@@ -255,15 +255,15 @@ impl DiagnosticMessage {
match args.get(i) {
Some(MessageArg::Code(t)) => {
plain.push_str(t);
if t.len() > 0 {
if !t.is_empty() {
let count = longest_backtick_sequence_length(t) + 1;
markdown.push_str(&"`".repeat(count));
if count > 1 {
markdown.push_str(" ");
markdown.push(' ');
}
markdown.push_str(t);
if count > 1 {
markdown.push_str(" ");
markdown.push(' ');
}
markdown.push_str(&"`".repeat(count));
}
@@ -271,11 +271,11 @@ impl DiagnosticMessage {
Some(MessageArg::Link(text, url)) => {
plain.push_str(text);
self.help_link(url);
markdown.push_str("[");
markdown.push('[');
markdown.push_str(text);
markdown.push_str("](");
markdown.push_str(url);
markdown.push_str(")");
markdown.push(')');
}
None => {}
}

View File

@@ -97,7 +97,7 @@ impl fmt::Display for Entry {
match self {
Entry::FreshId(label) => write!(f, "{}=*", label),
Entry::MapLabelToKey(label, key) => {
write!(f, "{}=@\"{}\"", label, key.replace("\"", "\"\""))
write!(f, "{}=@\"{}\"", label, key.replace('"', "\"\""))
}
Entry::GenericTuple(name, args) => {
write!(f, "{}(", name)?;
@@ -142,7 +142,7 @@ impl fmt::Display for Arg {
Arg::String(x) => write!(
f,
"\"{}\"",
limit_string(x, MAX_STRLEN).replace("\"", "\"\"")
limit_string(x, MAX_STRLEN).replace('"', "\"\"")
),
}
}