Optimize format usage
Per #112156, using `&` in `format!` may cause a small perf delay, so I tried to clean up one module at a time format usage. This PR includes a few removals of the ref in format (they do compile locally without the ref), as well as a few format inlining for consistency.
This commit is contained in:
parent
8771282d4e
commit
bb1ad0a2f1
@ -238,7 +238,7 @@ impl<'a> Parser<'a> {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
.into();
|
.into();
|
||||||
let invalid = format!("{}=", &sugg);
|
let invalid = format!("{sugg}=");
|
||||||
self.sess.emit_err(errors::InvalidComparisonOperator {
|
self.sess.emit_err(errors::InvalidComparisonOperator {
|
||||||
span: sp,
|
span: sp,
|
||||||
invalid: invalid.clone(),
|
invalid: invalid.clone(),
|
||||||
|
@ -157,15 +157,15 @@ fn emit_malformed_attribute(
|
|||||||
matches!(name, sym::doc | sym::ignore | sym::inline | sym::link | sym::test | sym::bench)
|
matches!(name, sym::doc | sym::ignore | sym::inline | sym::link | sym::test | sym::bench)
|
||||||
};
|
};
|
||||||
|
|
||||||
let error_msg = format!("malformed `{}` attribute input", name);
|
let error_msg = format!("malformed `{name}` attribute input");
|
||||||
let mut msg = "attribute must be of the form ".to_owned();
|
let mut msg = "attribute must be of the form ".to_owned();
|
||||||
let mut suggestions = vec![];
|
let mut suggestions = vec![];
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
let inner = if style == ast::AttrStyle::Inner { "!" } else { "" };
|
let inner = if style == ast::AttrStyle::Inner { "!" } else { "" };
|
||||||
if template.word {
|
if template.word {
|
||||||
first = false;
|
first = false;
|
||||||
let code = format!("#{}[{}]", inner, name);
|
let code = format!("#{inner}[{name}]");
|
||||||
msg.push_str(&format!("`{}`", &code));
|
msg.push_str(&format!("`{code}`"));
|
||||||
suggestions.push(code);
|
suggestions.push(code);
|
||||||
}
|
}
|
||||||
if let Some(descr) = template.list {
|
if let Some(descr) = template.list {
|
||||||
@ -173,16 +173,16 @@ fn emit_malformed_attribute(
|
|||||||
msg.push_str(" or ");
|
msg.push_str(" or ");
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
let code = format!("#{}[{}({})]", inner, name, descr);
|
let code = format!("#{inner}[{name}({descr})]");
|
||||||
msg.push_str(&format!("`{}`", &code));
|
msg.push_str(&format!("`{code}`"));
|
||||||
suggestions.push(code);
|
suggestions.push(code);
|
||||||
}
|
}
|
||||||
if let Some(descr) = template.name_value_str {
|
if let Some(descr) = template.name_value_str {
|
||||||
if !first {
|
if !first {
|
||||||
msg.push_str(" or ");
|
msg.push_str(" or ");
|
||||||
}
|
}
|
||||||
let code = format!("#{}[{} = \"{}\"]", inner, name, descr);
|
let code = format!("#{inner}[{name} = \"{descr}\"]");
|
||||||
msg.push_str(&format!("`{}`", &code));
|
msg.push_str(&format!("`{code}`"));
|
||||||
suggestions.push(code);
|
suggestions.push(code);
|
||||||
}
|
}
|
||||||
if should_warn(name) {
|
if should_warn(name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user