Use more named format args
This commit is contained in:
parent
a1a94b1c0f
commit
16b34bfae3
16 changed files with 130 additions and 85 deletions
|
@ -163,9 +163,9 @@ where
|
|||
fn get_lifetime(region: Region<'_>, names_map: &FxHashMap<Symbol, Lifetime>) -> Lifetime {
|
||||
region_name(region)
|
||||
.map(|name| {
|
||||
names_map.get(&name).unwrap_or_else(|| {
|
||||
panic!("Missing lifetime with name {:?} for {region:?}", name.as_str())
|
||||
})
|
||||
names_map
|
||||
.get(&name)
|
||||
.unwrap_or_else(|| panic!("Missing lifetime with name {name:?} for {region:?}"))
|
||||
})
|
||||
.unwrap_or(&Lifetime::statik())
|
||||
.clone()
|
||||
|
|
|
@ -601,7 +601,11 @@ pub(super) fn render_macro_arms<'a>(
|
|||
) -> String {
|
||||
let mut out = String::new();
|
||||
for matcher in matchers {
|
||||
writeln!(out, " {} => {{ ... }}{arm_delim}", render_macro_matcher(tcx, matcher))
|
||||
writeln!(
|
||||
out,
|
||||
" {matcher} => {{ ... }}{arm_delim}",
|
||||
matcher = render_macro_matcher(tcx, matcher),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
out
|
||||
|
@ -618,19 +622,21 @@ pub(super) fn display_macro_source(
|
|||
let matchers = def.body.tokens.chunks(4).map(|arm| &arm[0]);
|
||||
|
||||
if def.macro_rules {
|
||||
format!("macro_rules! {name} {{\n{}}}", render_macro_arms(cx.tcx, matchers, ";"))
|
||||
format!("macro_rules! {name} {{\n{arms}}}", arms = render_macro_arms(cx.tcx, matchers, ";"))
|
||||
} else {
|
||||
if matchers.len() <= 1 {
|
||||
format!(
|
||||
"{}macro {name}{} {{\n ...\n}}",
|
||||
visibility_to_src_with_space(Some(vis), cx.tcx, def_id),
|
||||
matchers.map(|matcher| render_macro_matcher(cx.tcx, matcher)).collect::<String>(),
|
||||
"{vis}macro {name}{matchers} {{\n ...\n}}",
|
||||
vis = visibility_to_src_with_space(Some(vis), cx.tcx, def_id),
|
||||
matchers = matchers
|
||||
.map(|matcher| render_macro_matcher(cx.tcx, matcher))
|
||||
.collect::<String>(),
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"{}macro {name} {{\n{}}}",
|
||||
visibility_to_src_with_space(Some(vis), cx.tcx, def_id),
|
||||
render_macro_arms(cx.tcx, matchers, ","),
|
||||
"{vis}macro {name} {{\n{arms}}}",
|
||||
vis = visibility_to_src_with_space(Some(vis), cx.tcx, def_id),
|
||||
arms = render_macro_arms(cx.tcx, matchers, ","),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,9 +72,9 @@ impl DocFS {
|
|||
let sender = self.errors.clone().expect("can't write after closing");
|
||||
self.pool.execute(move || {
|
||||
fs::write(&path, contents).unwrap_or_else(|e| {
|
||||
sender.send(format!("\"{}\": {e}", path.display())).unwrap_or_else(|_| {
|
||||
panic!("failed to send error on \"{}\"", path.display())
|
||||
})
|
||||
sender.send(format!("\"{path}\": {e}", path = path.display())).unwrap_or_else(
|
||||
|_| panic!("failed to send error on \"{}\"", path.display()),
|
||||
)
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -81,7 +81,11 @@ pub(crate) fn load_string<P: AsRef<Path>>(
|
|||
let contents = match fs::read(file_path) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(e) => {
|
||||
diag.struct_err(format!("error reading `{}`: {e}", file_path.display())).emit();
|
||||
diag.struct_err(format!(
|
||||
"error reading `{file_path}`: {e}",
|
||||
file_path = file_path.display()
|
||||
))
|
||||
.emit();
|
||||
return Err(LoadStringError::ReadFail);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -109,6 +109,10 @@ impl Buffer {
|
|||
self.buffer
|
||||
}
|
||||
|
||||
pub(crate) fn push(&mut self, c: char) {
|
||||
self.buffer.push(c);
|
||||
}
|
||||
|
||||
pub(crate) fn push_str(&mut self, s: &str) {
|
||||
self.buffer.push_str(s);
|
||||
}
|
||||
|
@ -451,9 +455,9 @@ impl clean::GenericBound {
|
|||
hir::TraitBoundModifier::MaybeConst => "",
|
||||
};
|
||||
if f.alternate() {
|
||||
write!(f, "{modifier_str}{:#}", ty.print(cx))
|
||||
write!(f, "{modifier_str}{ty:#}", ty = ty.print(cx))
|
||||
} else {
|
||||
write!(f, "{modifier_str}{}", ty.print(cx))
|
||||
write!(f, "{modifier_str}{ty}", ty = ty.print(cx))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -631,14 +635,14 @@ fn generate_macro_def_id_path(
|
|||
let url = match cache.extern_locations[&def_id.krate] {
|
||||
ExternalLocation::Remote(ref s) => {
|
||||
// `ExternalLocation::Remote` always end with a `/`.
|
||||
format!("{s}{}", path.iter().map(|p| p.as_str()).join("/"))
|
||||
format!("{s}{path}", path = path.iter().map(|p| p.as_str()).join("/"))
|
||||
}
|
||||
ExternalLocation::Local => {
|
||||
// `root_path` always end with a `/`.
|
||||
format!(
|
||||
"{}{crate_name}/{}",
|
||||
root_path.unwrap_or(""),
|
||||
path.iter().map(|p| p.as_str()).join("/")
|
||||
"{root_path}{crate_name}/{path}",
|
||||
root_path = root_path.unwrap_or(""),
|
||||
path = path.iter().map(|p| p.as_str()).join("/")
|
||||
)
|
||||
}
|
||||
ExternalLocation::Unknown => {
|
||||
|
@ -827,9 +831,9 @@ fn resolved_path<'cx>(
|
|||
let path = if use_absolute {
|
||||
if let Ok((_, _, fqp)) = href(did, cx) {
|
||||
format!(
|
||||
"{}::{}",
|
||||
join_with_double_colon(&fqp[..fqp.len() - 1]),
|
||||
anchor(did, *fqp.last().unwrap(), cx)
|
||||
"{path}::{anchor}",
|
||||
path = join_with_double_colon(&fqp[..fqp.len() - 1]),
|
||||
anchor = anchor(did, *fqp.last().unwrap(), cx)
|
||||
)
|
||||
} else {
|
||||
last.name.to_string()
|
||||
|
@ -837,7 +841,7 @@ fn resolved_path<'cx>(
|
|||
} else {
|
||||
anchor(did, last.name, cx).to_string()
|
||||
};
|
||||
write!(w, "{path}{}", last.args.print(cx))?;
|
||||
write!(w, "{path}{args}", args = last.args.print(cx))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -945,8 +949,8 @@ pub(crate) fn anchor<'a, 'cx: 'a>(
|
|||
if let Ok((url, short_ty, fqp)) = parts {
|
||||
write!(
|
||||
f,
|
||||
r#"<a class="{short_ty}" href="{url}" title="{short_ty} {}">{text}</a>"#,
|
||||
join_with_double_colon(&fqp),
|
||||
r#"<a class="{short_ty}" href="{url}" title="{short_ty} {path}">{text}</a>"#,
|
||||
path = join_with_double_colon(&fqp),
|
||||
)
|
||||
} else {
|
||||
f.write_str(text.as_str())
|
||||
|
@ -1080,9 +1084,9 @@ fn fmt_type<'cx>(
|
|||
|
||||
if matches!(**t, clean::Generic(_)) || t.is_assoc_ty() {
|
||||
let text = if f.alternate() {
|
||||
format!("*{m} {:#}", t.print(cx))
|
||||
format!("*{m} {ty:#}", ty = t.print(cx))
|
||||
} else {
|
||||
format!("*{m} {}", t.print(cx))
|
||||
format!("*{m} {ty}", ty = t.print(cx))
|
||||
};
|
||||
primitive_link(f, clean::PrimitiveType::RawPointer, &text, cx)
|
||||
} else {
|
||||
|
@ -1440,11 +1444,20 @@ impl clean::FnDecl {
|
|||
clean::SelfValue => {
|
||||
write!(f, "self")?;
|
||||
}
|
||||
clean::SelfBorrowed(Some(ref lt), mtbl) => {
|
||||
write!(f, "{amp}{} {}self", lt.print(), mtbl.print_with_space())?;
|
||||
clean::SelfBorrowed(Some(ref lt), mutability) => {
|
||||
write!(
|
||||
f,
|
||||
"{amp}{lifetime} {mutability}self",
|
||||
lifetime = lt.print(),
|
||||
mutability = mutability.print_with_space(),
|
||||
)?;
|
||||
}
|
||||
clean::SelfBorrowed(None, mtbl) => {
|
||||
write!(f, "{amp}{}self", mtbl.print_with_space())?;
|
||||
clean::SelfBorrowed(None, mutability) => {
|
||||
write!(
|
||||
f,
|
||||
"{amp}{mutability}self",
|
||||
mutability = mutability.print_with_space(),
|
||||
)?;
|
||||
}
|
||||
clean::SelfExplicit(ref typ) => {
|
||||
write!(f, "self: ")?;
|
||||
|
@ -1627,7 +1640,7 @@ impl clean::Import {
|
|||
if name == self.source.path.last() {
|
||||
write!(f, "use {};", self.source.print(cx))
|
||||
} else {
|
||||
write!(f, "use {} as {name};", self.source.print(cx))
|
||||
write!(f, "use {source} as {name};", source = self.source.print(cx))
|
||||
}
|
||||
}
|
||||
clean::ImportKind::Glob => {
|
||||
|
|
|
@ -937,7 +937,7 @@ fn string_without_closing_tag<T: Display>(
|
|||
write!(out, "{text}").unwrap();
|
||||
return None;
|
||||
}
|
||||
write!(out, "<span class=\"{}\">{text}", klass.as_html()).unwrap();
|
||||
write!(out, "<span class=\"{klass}\">{text}", klass = klass.as_html()).unwrap();
|
||||
return Some("</span>");
|
||||
};
|
||||
|
||||
|
@ -947,11 +947,15 @@ fn string_without_closing_tag<T: Display>(
|
|||
match t {
|
||||
"self" | "Self" => write!(
|
||||
&mut path,
|
||||
"<span class=\"{}\">{t}</span>",
|
||||
Class::Self_(DUMMY_SP).as_html(),
|
||||
"<span class=\"{klass}\">{t}</span>",
|
||||
klass = Class::Self_(DUMMY_SP).as_html(),
|
||||
),
|
||||
"crate" | "super" => {
|
||||
write!(&mut path, "<span class=\"{}\">{t}</span>", Class::KeyWord.as_html())
|
||||
write!(
|
||||
&mut path,
|
||||
"<span class=\"{klass}\">{t}</span>",
|
||||
klass = Class::KeyWord.as_html(),
|
||||
)
|
||||
}
|
||||
t => write!(&mut path, "{t}"),
|
||||
}
|
||||
|
|
|
@ -246,9 +246,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
|
|||
return Some(Event::Html(
|
||||
format!(
|
||||
"<div class=\"example-wrap\">\
|
||||
<pre class=\"language-{lang}\"><code>{}</code></pre>\
|
||||
<pre class=\"language-{lang}\"><code>{text}</code></pre>\
|
||||
</div>",
|
||||
Escape(&original_text),
|
||||
text = Escape(&original_text),
|
||||
)
|
||||
.into(),
|
||||
));
|
||||
|
@ -308,7 +308,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
|
|||
// insert newline to clearly separate it from the
|
||||
// previous block so we can shorten the html output
|
||||
let mut s = Buffer::new();
|
||||
s.push_str("\n");
|
||||
s.push('\n');
|
||||
|
||||
highlight::render_example_with_highlighting(
|
||||
&text,
|
||||
|
@ -394,7 +394,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for LinkReplacer<'a, I> {
|
|||
l.href == link.href
|
||||
&& Some(&**text) == l.original_text.get(1..l.original_text.len() - 1)
|
||||
}) {
|
||||
debug!("replacing {text} with {}", link.new_text);
|
||||
debug!("replacing {text} with {new_text}", new_text = link.new_text);
|
||||
*text = CowStr::Borrowed(&link.new_text);
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for LinkReplacer<'a, I> {
|
|||
.iter()
|
||||
.find(|l| l.href == link.href && **text == *l.original_text)
|
||||
{
|
||||
debug!("replacing {text} with {}", link.new_text);
|
||||
debug!("replacing {text} with {new_text}", new_text = link.new_text);
|
||||
*text = CowStr::Borrowed(&link.new_text);
|
||||
}
|
||||
}
|
||||
|
@ -1038,7 +1038,7 @@ impl MarkdownWithToc<'_> {
|
|||
html::push_html(&mut s, p);
|
||||
}
|
||||
|
||||
format!("<nav id=\"TOC\">{}</nav>{s}", toc.into_toc().print())
|
||||
format!("<nav id=\"TOC\">{toc}</nav>{s}", toc = toc.into_toc().print())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,9 +206,9 @@ impl<'tcx> Context<'tcx> {
|
|||
format!("API documentation for the Rust `{}` crate.", self.shared.layout.krate)
|
||||
} else {
|
||||
format!(
|
||||
"API documentation for the Rust `{}` {tyname} in crate `{}`.",
|
||||
it.name.as_ref().unwrap(),
|
||||
self.shared.layout.krate
|
||||
"API documentation for the Rust `{name}` {tyname} in crate `{krate}`.",
|
||||
name = it.name.as_ref().unwrap(),
|
||||
krate = self.shared.layout.krate,
|
||||
)
|
||||
};
|
||||
let name;
|
||||
|
@ -263,7 +263,12 @@ impl<'tcx> Context<'tcx> {
|
|||
current_path.push_str(&item_path(ty, names.last().unwrap().as_str()));
|
||||
redirections.borrow_mut().insert(current_path, path);
|
||||
}
|
||||
None => return layout::redirect(&format!("{}{path}", self.root_path())),
|
||||
None => {
|
||||
return layout::redirect(&format!(
|
||||
"{root}{path}",
|
||||
root = self.root_path()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -565,10 +565,10 @@ fn portability(item: &clean::Item, parent: Option<&clean::Item>) -> Option<Strin
|
|||
};
|
||||
|
||||
debug!(
|
||||
"Portability {:?} {:?} (parent: {parent:?}) - {:?} = {cfg:?}",
|
||||
item.name,
|
||||
item.cfg,
|
||||
parent.and_then(|p| p.cfg.as_ref()),
|
||||
"Portability {name:?} {item_cfg:?} (parent: {parent:?}) - {parent_cfg:?} = {cfg:?}",
|
||||
name = item.name,
|
||||
item_cfg = item.cfg,
|
||||
parent_cfg = parent.and_then(|p| p.cfg.as_ref()),
|
||||
);
|
||||
|
||||
Some(cfg?.render_long_html())
|
||||
|
@ -1243,7 +1243,10 @@ fn render_deref_methods(
|
|||
_ => None,
|
||||
})
|
||||
.expect("Expected associated type binding");
|
||||
debug!("Render deref methods for {:#?}, target {target:#?}", impl_.inner_impl().for_);
|
||||
debug!(
|
||||
"Render deref methods for {for_:#?}, target {target:#?}",
|
||||
for_ = impl_.inner_impl().for_
|
||||
);
|
||||
let what =
|
||||
AssocItemRender::DerefFor { trait_: deref_type, type_: real_target, deref_mut_: deref_mut };
|
||||
if let Some(did) = target.def_id(cache) {
|
||||
|
|
|
@ -581,8 +581,8 @@ fn extra_info_tags<'a, 'tcx: 'a>(
|
|||
display_fn(move |f| {
|
||||
write!(
|
||||
f,
|
||||
r#"<span class="stab {class}" title="{}">{contents}</span>"#,
|
||||
Escape(title),
|
||||
r#"<span class="stab {class}" title="{title}">{contents}</span>"#,
|
||||
title = Escape(title),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -610,7 +610,12 @@ fn extra_info_tags<'a, 'tcx: 'a>(
|
|||
(cfg, _) => cfg.as_deref().cloned(),
|
||||
};
|
||||
|
||||
debug!("Portability name={:?} {:?} - {:?} = {cfg:?}", item.name, item.cfg, parent.cfg);
|
||||
debug!(
|
||||
"Portability name={name:?} {cfg:?} - {parent_cfg:?} = {cfg:?}",
|
||||
name = item.name,
|
||||
cfg = item.cfg,
|
||||
parent_cfg = parent.cfg
|
||||
);
|
||||
if let Some(ref cfg) = cfg {
|
||||
write!(
|
||||
f,
|
||||
|
@ -737,9 +742,10 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
|
|||
toggle_open(
|
||||
&mut w,
|
||||
format_args!(
|
||||
"{count_consts} associated constant{} and {count_methods} method{}",
|
||||
pluralize(count_consts),
|
||||
pluralize(count_methods),
|
||||
"{count_consts} associated constant{plural_const} and \
|
||||
{count_methods} method{plural_method}",
|
||||
plural_const = pluralize(count_consts),
|
||||
plural_method = pluralize(count_methods),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -830,7 +836,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
|
|||
|
||||
fn trait_item(w: &mut Buffer, cx: &mut Context<'_>, m: &clean::Item, t: &clean::Item) {
|
||||
let name = m.name.unwrap();
|
||||
info!("Documenting {name} on {:?}", t.name);
|
||||
info!("Documenting {name} on {ty_name:?}", ty_name = t.name);
|
||||
let item_type = m.type_();
|
||||
let id = cx.derive_id(format!("{item_type}.{name}"));
|
||||
let mut content = Buffer::empty_from(w);
|
||||
|
@ -1610,7 +1616,7 @@ fn item_struct(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean
|
|||
for (index, (field, ty)) in fields.enumerate() {
|
||||
let field_name =
|
||||
field.name.map_or_else(|| index.to_string(), |sym| sym.as_str().to_string());
|
||||
let id = cx.derive_id(format!("{}.{field_name}", ItemType::StructField));
|
||||
let id = cx.derive_id(format!("{typ}.{field_name}", typ = ItemType::StructField));
|
||||
write!(
|
||||
w,
|
||||
"<span id=\"{id}\" class=\"{item_type} small-section-header\">\
|
||||
|
@ -1907,10 +1913,10 @@ fn render_struct(
|
|||
if let clean::StructFieldItem(ref ty) = *field.kind {
|
||||
write!(
|
||||
w,
|
||||
"\n{tab} {}{}: {},",
|
||||
visibility_print_with_space(field.visibility(tcx), field.item_id, cx),
|
||||
field.name.unwrap(),
|
||||
ty.print(cx),
|
||||
"\n{tab} {vis}{name}: {ty},",
|
||||
vis = visibility_print_with_space(field.visibility(tcx), field.item_id, cx),
|
||||
name = field.name.unwrap(),
|
||||
ty = ty.print(cx),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -529,7 +529,7 @@ fn get_methods<'a>(
|
|||
Some(ref name) if !name.is_empty() && item.is_method() => {
|
||||
if !for_deref || super::should_render_item(item, deref_mut, tcx) {
|
||||
Some(Link::new(
|
||||
get_next_url(used_links, format!("{}.{name}", ItemType::Method)),
|
||||
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::Method)),
|
||||
name.as_str(),
|
||||
))
|
||||
} else {
|
||||
|
@ -549,7 +549,7 @@ fn get_associated_constants<'a>(
|
|||
.iter()
|
||||
.filter_map(|item| match item.name {
|
||||
Some(ref name) if !name.is_empty() && item.is_associated_const() => Some(Link::new(
|
||||
get_next_url(used_links, format!("{}.{name}", ItemType::AssocConst)),
|
||||
get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocConst)),
|
||||
name.as_str(),
|
||||
)),
|
||||
_ => None,
|
||||
|
|
|
@ -73,7 +73,7 @@ pub(super) fn write_shared(
|
|||
}
|
||||
|
||||
let bytes = try_err!(fs::read(&entry.path), &entry.path);
|
||||
let filename = format!("{theme}{}.{extension}", cx.shared.resource_suffix);
|
||||
let filename = format!("{theme}{suffix}.{extension}", suffix = cx.shared.resource_suffix);
|
||||
cx.shared.fs.write(cx.dst.join(filename), bytes)?;
|
||||
}
|
||||
|
||||
|
@ -349,8 +349,8 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
|
|||
.iter()
|
||||
.map(|s| {
|
||||
format!(
|
||||
"<li><a href=\"{}index.html\">{s}</a></li>",
|
||||
ensure_trailing_slash(s),
|
||||
"<li><a href=\"{trailing_slash}index.html\">{s}</a></li>",
|
||||
trailing_slash = ensure_trailing_slash(s),
|
||||
)
|
||||
})
|
||||
.collect::<String>()
|
||||
|
|
|
@ -146,8 +146,8 @@ impl DocVisitor for SourceCollector<'_, '_> {
|
|||
self.cx.shared.tcx.sess.span_err(
|
||||
span,
|
||||
format!(
|
||||
"failed to render source code for `{}`: {e}",
|
||||
filename.prefer_local(),
|
||||
"failed to render source code for `{filename}`: {e}",
|
||||
filename = filename.prefer_local(),
|
||||
),
|
||||
);
|
||||
false
|
||||
|
|
|
@ -43,7 +43,7 @@ pub(crate) fn render<P: AsRef<Path>>(
|
|||
edition: Edition,
|
||||
) -> Result<(), String> {
|
||||
if let Err(e) = create_dir_all(&options.output) {
|
||||
return Err(format!("{}: {e}", options.output.display()));
|
||||
return Err(format!("{output}: {e}", output = options.output.display()));
|
||||
}
|
||||
|
||||
let input = input.as_ref();
|
||||
|
@ -57,11 +57,13 @@ pub(crate) fn render<P: AsRef<Path>>(
|
|||
.expect("Writing to a String can't fail");
|
||||
}
|
||||
|
||||
let input_str = read_to_string(input).map_err(|err| format!("{}: {err}", input.display()))?;
|
||||
let input_str =
|
||||
read_to_string(input).map_err(|err| format!("{input}: {err}", input = input.display()))?;
|
||||
let playground_url = options.markdown_playground_url.or(options.playground_url);
|
||||
let playground = playground_url.map(|url| markdown::Playground { crate_name: None, url });
|
||||
|
||||
let mut out = File::create(&output).map_err(|e| format!("{}: {e}", output.display()))?;
|
||||
let mut out =
|
||||
File::create(&output).map_err(|e| format!("{output}: {e}", output = output.display()))?;
|
||||
|
||||
let (metadata, text) = extract_leading_metadata(&input_str);
|
||||
if metadata.is_empty() {
|
||||
|
@ -129,7 +131,7 @@ pub(crate) fn render<P: AsRef<Path>>(
|
|||
);
|
||||
|
||||
match err {
|
||||
Err(e) => Err(format!("cannot write to `{}`: {e}", output.display())),
|
||||
Err(e) => Err(format!("cannot write to `{output}`: {e}", output = output.display())),
|
||||
Ok(_) => Ok(()),
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +139,7 @@ pub(crate) fn render<P: AsRef<Path>>(
|
|||
/// Runs any tests/code examples in the markdown file `input`.
|
||||
pub(crate) fn test(options: Options) -> Result<(), String> {
|
||||
let input_str = read_to_string(&options.input)
|
||||
.map_err(|err| format!("{}: {err}", options.input.display()))?;
|
||||
.map_err(|err| format!("{input}: {err}", input = options.input.display()))?;
|
||||
let mut opts = GlobalTestOptions::default();
|
||||
opts.no_crate_inject = true;
|
||||
let mut collector = Collector::new(
|
||||
|
|
|
@ -146,8 +146,10 @@ impl<'a, 'b> CoverageCalculator<'a, 'b> {
|
|||
examples_percentage: f64,
|
||||
) {
|
||||
println!(
|
||||
"| {name:<35} | {:>10} | {percentage:>9.1}% | {:>10} | {:>9.1}% |",
|
||||
count.with_docs, count.with_examples, examples_percentage,
|
||||
"| {name:<35} | {with_docs:>10} | {percentage:>9.1}% | {with_examples:>10} | \
|
||||
{examples_percentage:>9.1}% |",
|
||||
with_docs = count.with_docs,
|
||||
with_examples = count.with_examples,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -790,8 +790,8 @@ fn trait_impls_for<'a>(
|
|||
// Check if these are the same type.
|
||||
let impl_type = trait_ref.skip_binder().self_ty();
|
||||
trace!(
|
||||
"comparing type {impl_type} with kind {:?} against type {ty:?}",
|
||||
impl_type.kind(),
|
||||
"comparing type {impl_type} with kind {kind:?} against type {ty:?}",
|
||||
kind = impl_type.kind(),
|
||||
);
|
||||
// Fast path: if this is a primitive simple `==` will work
|
||||
// NOTE: the `match` is necessary; see #92662.
|
||||
|
@ -1876,9 +1876,9 @@ fn resolution_failure(
|
|||
};
|
||||
let name = res.name(tcx);
|
||||
let note = format!(
|
||||
"the {} `{name}` has no {} named `{unresolved}`",
|
||||
res.descr(),
|
||||
disambiguator.map_or(path_description, |d| d.descr()),
|
||||
"the {res} `{name}` has no {disamb_res} named `{unresolved}`",
|
||||
res = res.descr(),
|
||||
disamb_res = disambiguator.map_or(path_description, |d| d.descr()),
|
||||
);
|
||||
if let Some(span) = sp {
|
||||
diag.span_label(span, note);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue