Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoerister
Simplify some nested `if` statements Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if` Review with whitespace disabled please.
This commit is contained in:
commit
3ba12756d3
61 changed files with 563 additions and 671 deletions
|
@ -281,12 +281,10 @@ pub fn each_linked_rlib(
|
|||
let used_crate_source = &info.used_crate_source[&cnum];
|
||||
if let Some((path, _)) = &used_crate_source.rlib {
|
||||
f(cnum, path);
|
||||
} else if used_crate_source.rmeta.is_some() {
|
||||
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
if used_crate_source.rmeta.is_some() {
|
||||
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
return Err(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
return Err(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -628,12 +626,10 @@ fn link_staticlib(
|
|||
let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum];
|
||||
if let Some((path, _)) = &used_crate_source.dylib {
|
||||
all_rust_dylibs.push(&**path);
|
||||
} else if used_crate_source.rmeta.is_some() {
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
if used_crate_source.rmeta.is_some() {
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1972,10 +1968,8 @@ fn add_late_link_args(
|
|||
if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
} else {
|
||||
if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
} else if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
if let Some(args) = sess.target.late_link_args.get(&flavor) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
|
@ -2635,10 +2629,8 @@ fn add_native_libs_from_crate(
|
|||
if link_static {
|
||||
cmd.link_staticlib_by_name(name, verbatim, false);
|
||||
}
|
||||
} else {
|
||||
if link_dynamic {
|
||||
cmd.link_dylib_by_name(name, verbatim, true);
|
||||
}
|
||||
} else if link_dynamic {
|
||||
cmd.link_dylib_by_name(name, verbatim, true);
|
||||
}
|
||||
}
|
||||
NativeLibKind::Framework { as_needed } => {
|
||||
|
|
|
@ -791,14 +791,12 @@ impl<'a> Linker for GccLinker<'a> {
|
|||
self.link_arg("-exported_symbols_list").link_arg(path);
|
||||
} else if self.sess.target.is_like_solaris {
|
||||
self.link_arg("-M").link_arg(path);
|
||||
} else if is_windows {
|
||||
self.link_arg(path);
|
||||
} else {
|
||||
if is_windows {
|
||||
self.link_arg(path);
|
||||
} else {
|
||||
let mut arg = OsString::from("--version-script=");
|
||||
arg.push(path);
|
||||
self.link_arg(arg).link_arg("--no-undefined-version");
|
||||
}
|
||||
let mut arg = OsString::from("--version-script=");
|
||||
arg.push(path);
|
||||
self.link_arg(arg).link_arg("--no-undefined-version");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -617,32 +617,29 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
|||
// purpose functions as they wouldn't have the right target features
|
||||
// enabled. For that reason we also forbid #[inline(always)] as it can't be
|
||||
// respected.
|
||||
if !codegen_fn_attrs.target_features.is_empty() {
|
||||
if codegen_fn_attrs.inline == InlineAttr::Always {
|
||||
if let Some(span) = inline_span {
|
||||
tcx.dcx().span_err(
|
||||
span,
|
||||
"cannot use `#[inline(always)]` with \
|
||||
if !codegen_fn_attrs.target_features.is_empty() && codegen_fn_attrs.inline == InlineAttr::Always
|
||||
{
|
||||
if let Some(span) = inline_span {
|
||||
tcx.dcx().span_err(
|
||||
span,
|
||||
"cannot use `#[inline(always)]` with \
|
||||
`#[target_feature]`",
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if !codegen_fn_attrs.no_sanitize.is_empty() {
|
||||
if codegen_fn_attrs.inline == InlineAttr::Always {
|
||||
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
|
||||
let hir_id = tcx.local_def_id_to_hir_id(did);
|
||||
tcx.node_span_lint(
|
||||
lint::builtin::INLINE_NO_SANITIZE,
|
||||
hir_id,
|
||||
no_sanitize_span,
|
||||
|lint| {
|
||||
lint.primary_message("`no_sanitize` will have no effect after inlining");
|
||||
lint.span_note(inline_span, "inlining requested here");
|
||||
},
|
||||
)
|
||||
}
|
||||
if !codegen_fn_attrs.no_sanitize.is_empty() && codegen_fn_attrs.inline == InlineAttr::Always {
|
||||
if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
|
||||
let hir_id = tcx.local_def_id_to_hir_id(did);
|
||||
tcx.node_span_lint(
|
||||
lint::builtin::INLINE_NO_SANITIZE,
|
||||
hir_id,
|
||||
no_sanitize_span,
|
||||
|lint| {
|
||||
lint.primary_message("`no_sanitize` will have no effect after inlining");
|
||||
lint.span_note(inline_span, "inlining requested here");
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,15 +236,13 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
let has_enclosing_parens = if cpp_like_debuginfo {
|
||||
output.push_str("dyn$<");
|
||||
false
|
||||
} else if trait_data.len() > 1 && auto_traits.len() != 0 {
|
||||
// We need enclosing parens because there is more than one trait
|
||||
output.push_str("(dyn ");
|
||||
true
|
||||
} else {
|
||||
if trait_data.len() > 1 && auto_traits.len() != 0 {
|
||||
// We need enclosing parens because there is more than one trait
|
||||
output.push_str("(dyn ");
|
||||
true
|
||||
} else {
|
||||
output.push_str("dyn ");
|
||||
false
|
||||
}
|
||||
output.push_str("dyn ");
|
||||
false
|
||||
};
|
||||
|
||||
if let Some(principal) = trait_data.principal() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue