Manual, post-clippy --fix cleanups

This commit is contained in:
Yotam Ofek 2025-03-01 19:12:21 +00:00
parent 329b8a312d
commit 5d259224bd
6 changed files with 18 additions and 23 deletions

View file

@ -2539,7 +2539,7 @@ fn clean_generic_args<'tcx>(
) -> GenericArgs {
// FIXME(return_type_notation): Fix RTN parens rendering
if let Some((inputs, output)) = generic_args.paren_sugar_inputs_output() {
let inputs = inputs.iter().map(|x| clean_ty(x, cx)).collect::<ThinVec<_>>();
let inputs = inputs.iter().map(|x| clean_ty(x, cx)).collect();
let output = match output.kind {
hir::TyKind::Tup(&[]) => None,
_ => Some(Box::new(clean_ty(output, cx))),
@ -2560,7 +2560,7 @@ fn clean_generic_args<'tcx>(
}
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
})
.collect::<ThinVec<_>>();
.collect();
let constraints = generic_args
.constraints
.iter()

View file

@ -223,7 +223,7 @@ fn clean_middle_generic_args_with_constraints<'tcx>(
let args = clean_middle_generic_args(cx, args.map_bound(|args| &args[..]), has_self, did);
GenericArgs::AngleBracketed { args: args, constraints }
GenericArgs::AngleBracketed { args, constraints }
}
pub(super) fn clean_middle_path<'tcx>(
@ -394,7 +394,7 @@ pub(crate) fn print_evaluated_const(
fn format_integer_with_underscore_sep(num: &str) -> String {
let num_chars: Vec<_> = num.chars().collect();
let mut num_start_index = if num_chars.first() == Some(&'-') { 1 } else { 0 };
let chunk_size = match num[num_start_index..].as_bytes() {
let chunk_size = match &num.as_bytes()[num_start_index..] {
[b'0', b'b' | b'x', ..] => {
num_start_index += 2;
4

View file

@ -623,9 +623,9 @@ pub(crate) fn href_relative_parts<'fqp>(
// e.g. linking to std::iter from std::vec (`dissimilar_part_count` will be 1)
if f != r {
let dissimilar_part_count = relative_to_fqp.len() - i;
let fqp_module = &fqp[i..fqp.len()];
let fqp_module = &fqp[i..];
return Box::new(
std::iter::repeat_n(sym::dotdot, dissimilar_part_count)
iter::repeat_n(sym::dotdot, dissimilar_part_count)
.chain(fqp_module.iter().copied()),
);
}
@ -638,7 +638,7 @@ pub(crate) fn href_relative_parts<'fqp>(
Ordering::Greater => {
// e.g. linking to std::sync from std::sync::atomic
let dissimilar_part_count = relative_to_fqp.len() - fqp.len();
Box::new(std::iter::repeat_n(sym::dotdot, dissimilar_part_count))
Box::new(iter::repeat_n(sym::dotdot, dissimilar_part_count))
}
Ordering::Equal => {
// linking to the same module
@ -769,9 +769,9 @@ fn primitive_link_fragment(
ExternalLocation::Local => {
let cname_sym = ExternalCrate { crate_num: def_id.krate }.name(cx.tcx());
Some(if cx.current.first() == Some(&cname_sym) {
std::iter::repeat_n(sym::dotdot, cx.current.len() - 1).collect()
iter::repeat_n(sym::dotdot, cx.current.len() - 1).collect()
} else {
std::iter::repeat_n(sym::dotdot, cx.current.len())
iter::repeat_n(sym::dotdot, cx.current.len())
.chain(iter::once(cname_sym))
.collect()
})

View file

@ -131,7 +131,7 @@ fn write_header(
/// * If the other `Class` is unclassified and only contains white characters (backline,
/// whitespace, etc), it can be merged.
/// * `Class::Ident` is considered the same as unclassified (because it doesn't have an associated
/// CSS class).
/// CSS class).
fn can_merge(class1: Option<Class>, class2: Option<Class>, text: &str) -> bool {
match (class1, class2) {
(Some(c1), Some(c2)) => c1.is_equal_to(c2),

View file

@ -1,6 +1,6 @@
use std::cmp::Ordering;
use std::fmt;
use std::fmt::{Display, Write as _};
use std::fmt::{self, Display, Write as _};
use std::iter;
use rinja::Template;
use rustc_abi::VariantIdx;
@ -1192,9 +1192,8 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt:
// to already be in the HTML, and will be ignored.
//
// [JSONP]: https://en.wikipedia.org/wiki/JSONP
let mut js_src_path: UrlPartsBuilder = std::iter::repeat_n("..", cx.current.len())
.chain(std::iter::once("trait.impl"))
.collect();
let mut js_src_path: UrlPartsBuilder =
iter::repeat_n("..", cx.current.len()).chain(iter::once("trait.impl")).collect();
if let Some(did) = it.item_id.as_def_id()
&& let get_extern = { || cx.shared.cache.external_paths.get(&did).map(|s| &s.0) }
&& let Some(fqp) = cx.shared.cache.exact_paths.get(&did).or_else(get_extern)
@ -1445,9 +1444,8 @@ fn item_type_alias(cx: &Context<'_>, it: &clean::Item, t: &clean::TypeAlias) ->
&& let get_local = { || cache.paths.get(&self_did).map(|(p, _)| p) }
&& let Some(self_fqp) = cache.exact_paths.get(&self_did).or_else(get_local)
{
let mut js_src_path: UrlPartsBuilder = std::iter::repeat_n("..", cx.current.len())
.chain(std::iter::once("type.impl"))
.collect();
let mut js_src_path: UrlPartsBuilder =
iter::repeat_n("..", cx.current.len()).chain(iter::once("type.impl")).collect();
js_src_path.extend(target_fqp[..target_fqp.len() - 1].iter().copied());
js_src_path.push_fmt(format_args!("{target_type}.{}.js", target_fqp.last().unwrap()));
let self_path = fmt::from_fn(|f| self_fqp.iter().joined("::", f));
@ -1491,7 +1489,7 @@ fn item_union(cx: &Context<'_>, it: &clean::Item, s: &clean::Union) -> impl fmt:
fn fields_iter(
&self,
) -> std::iter::Peekable<impl Iterator<Item = (&'a clean::Item, &'a clean::Type)>> {
) -> iter::Peekable<impl Iterator<Item = (&'a clean::Item, &'a clean::Type)>> {
self.s
.fields
.iter()

View file

@ -842,10 +842,7 @@ pub(crate) fn get_function_type_for_search(
}
clean::ConstantItem(ref c) => make_nullary_fn(&c.type_),
clean::StaticItem(ref s) => make_nullary_fn(&s.type_),
clean::StructFieldItem(ref t) => {
let Some(parent) = parent else {
return None;
};
clean::StructFieldItem(ref t) if let Some(parent) = parent => {
let mut rgen: FxIndexMap<SimplifiedParam, (isize, Vec<RenderType>)> =
Default::default();
let output = get_index_type(t, vec![], &mut rgen);