a couple clippy::complexity fixes
map_identity filter_next option_as_ref_deref unnecessary_find_map redundant_slicing unnecessary_unwrap bool_comparison derivable_impls manual_flatten needless_borrowed_reference
This commit is contained in:
parent
0196c2bd27
commit
8ef3bf29fe
10 changed files with 20 additions and 33 deletions
|
@ -1190,8 +1190,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
// Set KCFI operand bundle
|
||||
let is_indirect_call = unsafe { llvm::LLVMIsAFunction(llfn).is_none() };
|
||||
let kcfi_bundle =
|
||||
if self.tcx.sess.is_sanitizer_kcfi_enabled() && fn_abi.is_some() && is_indirect_call {
|
||||
let kcfi_typeid = kcfi_typeid_for_fnabi(self.tcx, fn_abi.unwrap());
|
||||
if let Some(fn_abi) = fn_abi && self.tcx.sess.is_sanitizer_kcfi_enabled() && is_indirect_call {
|
||||
let kcfi_typeid = kcfi_typeid_for_fnabi(self.tcx, fn_abi);
|
||||
Some(llvm::OperandBundleDef::new("kcfi", &[self.const_u32(kcfi_typeid)]))
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -2235,7 +2235,7 @@ impl EmitterWriter {
|
|||
}
|
||||
} else if is_multiline {
|
||||
buffer.puts(*row_num, 0, &self.maybe_anonymized(line_num), Style::LineNumber);
|
||||
match &highlight_parts[..] {
|
||||
match &highlight_parts {
|
||||
[SubstitutionHighlight { start: 0, end }] if *end == line_to_add.len() => {
|
||||
buffer.puts(*row_num, max_line_num_len + 1, "+ ", Style::Addition);
|
||||
}
|
||||
|
|
|
@ -2399,10 +2399,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
let suggestion =
|
||||
if has_lifetimes { format!(" + {}", sub) } else { format!(": {}", sub) };
|
||||
let mut suggestions = vec![(sp, suggestion)];
|
||||
for add_lt_sugg in add_lt_suggs {
|
||||
if let Some(add_lt_sugg) = add_lt_sugg {
|
||||
suggestions.push(add_lt_sugg);
|
||||
}
|
||||
for add_lt_sugg in add_lt_suggs.into_iter().flatten() {
|
||||
suggestions.push(add_lt_sugg);
|
||||
}
|
||||
err.multipart_suggestion_verbose(
|
||||
format!("{msg}..."),
|
||||
|
@ -2426,11 +2424,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
};
|
||||
let mut sugg =
|
||||
vec![(sp, suggestion), (span.shrink_to_hi(), format!(" + {}", new_lt))];
|
||||
for add_lt_sugg in add_lt_suggs.clone() {
|
||||
if let Some(lt) = add_lt_sugg {
|
||||
sugg.push(lt);
|
||||
sugg.rotate_right(1);
|
||||
}
|
||||
for lt in add_lt_suggs.clone().into_iter().flatten() {
|
||||
sugg.push(lt);
|
||||
sugg.rotate_right(1);
|
||||
}
|
||||
// `MaybeIncorrect` due to issue #41966.
|
||||
err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
|
||||
|
|
|
@ -651,8 +651,8 @@ fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
|
|||
let (shrunk, written_to_path) = shrunk_instance_name(tcx, &instance);
|
||||
let span = tcx.def_span(instance.def_id());
|
||||
let mut path = PathBuf::new();
|
||||
let was_written = if written_to_path.is_some() {
|
||||
path = written_to_path.unwrap();
|
||||
let was_written = if let Some(path2) = written_to_path {
|
||||
path = path2;
|
||||
Some(())
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -109,7 +109,7 @@ fn assert_default_hashing_controls<CTX: HashStableContext>(ctx: &CTX, msg: &str)
|
|||
// This is the case for instance when building a hash for name mangling.
|
||||
// Such configuration must not be used for metadata.
|
||||
HashingControls { hash_spans }
|
||||
if hash_spans == !ctx.unstable_opts_incremental_ignore_spans() => {}
|
||||
if hash_spans != ctx.unstable_opts_incremental_ignore_spans() => {}
|
||||
other => panic!("Attempted hashing of {msg} with non-default HashingControls: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3888,8 +3888,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
if let Some(slice_ty) = candidate_impls
|
||||
.iter()
|
||||
.map(|trait_ref| trait_ref.trait_ref.self_ty())
|
||||
.filter(|t| is_slice(*t))
|
||||
.next()
|
||||
.find(|t| is_slice(*t))
|
||||
{
|
||||
let msg = &format!("convert the array to a `{}` slice instead", slice_ty);
|
||||
|
||||
|
@ -3936,7 +3935,7 @@ fn hint_missing_borrow<'tcx>(
|
|||
// This could be a variant constructor, for example.
|
||||
let Some(fn_decl) = found_node.fn_decl() else { return; };
|
||||
|
||||
let args = fn_decl.inputs.iter().map(|ty| ty);
|
||||
let args = fn_decl.inputs.iter();
|
||||
|
||||
fn get_deref_type_and_refs(mut ty: Ty<'_>) -> (Ty<'_>, Vec<hir::Mutability>) {
|
||||
let mut refs = vec![];
|
||||
|
|
|
@ -31,18 +31,13 @@ use crate::passes::{self, Condition};
|
|||
use crate::scrape_examples::{AllCallLocations, ScrapeExamplesOptions};
|
||||
use crate::theme;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
|
||||
pub(crate) enum OutputFormat {
|
||||
Json,
|
||||
#[default]
|
||||
Html,
|
||||
}
|
||||
|
||||
impl Default for OutputFormat {
|
||||
fn default() -> OutputFormat {
|
||||
OutputFormat::Html
|
||||
}
|
||||
}
|
||||
|
||||
impl OutputFormat {
|
||||
pub(crate) fn is_json(&self) -> bool {
|
||||
matches!(self, OutputFormat::Json)
|
||||
|
|
|
@ -177,8 +177,8 @@ impl<'a, 'tcx, F: Write> TokenHandler<'a, 'tcx, F> {
|
|||
} else {
|
||||
// We only want to "open" the tag ourselves if we have more than one pending and if the
|
||||
// current parent tag is not the same as our pending content.
|
||||
let close_tag = if self.pending_elems.len() > 1 && current_class.is_some() {
|
||||
Some(enter_span(self.out, current_class.unwrap(), &self.href_context))
|
||||
let close_tag = if self.pending_elems.len() > 1 && let Some(current_class) = current_class {
|
||||
Some(enter_span(self.out, current_class, &self.href_context))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -113,11 +113,8 @@ pub(super) fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buf
|
|||
} else {
|
||||
("", "")
|
||||
};
|
||||
let version = if it.is_crate() {
|
||||
cx.cache().crate_version.as_ref().map(String::as_str).unwrap_or_default()
|
||||
} else {
|
||||
""
|
||||
};
|
||||
let version =
|
||||
if it.is_crate() { cx.cache().crate_version.as_deref().unwrap_or_default() } else { "" };
|
||||
let path: String = if !it.is_mod() {
|
||||
cx.current.iter().map(|s| s.as_str()).intersperse("::").collect()
|
||||
} else {
|
||||
|
|
|
@ -810,7 +810,7 @@ fn trait_impls_for<'a>(
|
|||
///
|
||||
/// These are common and we should just resolve to the trait in that case.
|
||||
fn is_derive_trait_collision<T>(ns: &PerNS<Result<Vec<(Res, T)>, ResolutionFailure<'_>>>) -> bool {
|
||||
if let (&Ok(ref type_ns), &Ok(ref macro_ns)) = (&ns.type_ns, &ns.macro_ns) {
|
||||
if let (Ok(type_ns), Ok(macro_ns)) = (&ns.type_ns, &ns.macro_ns) {
|
||||
type_ns.iter().any(|(res, _)| matches!(res, Res::Def(DefKind::Trait, _)))
|
||||
&& macro_ns
|
||||
.iter()
|
||||
|
|
Loading…
Add table
Reference in a new issue