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
|
@ -2169,17 +2169,13 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
attr.span,
|
||||
errors::MacroExport::TooManyItems,
|
||||
);
|
||||
} else {
|
||||
if meta_item_list[0].name_or_empty() != sym::local_inner_macros {
|
||||
self.tcx.emit_node_span_lint(
|
||||
INVALID_MACRO_EXPORT_ARGUMENTS,
|
||||
hir_id,
|
||||
meta_item_list[0].span(),
|
||||
errors::MacroExport::UnknownItem {
|
||||
name: meta_item_list[0].name_or_empty(),
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if meta_item_list[0].name_or_empty() != sym::local_inner_macros {
|
||||
self.tcx.emit_node_span_lint(
|
||||
INVALID_MACRO_EXPORT_ARGUMENTS,
|
||||
hir_id,
|
||||
meta_item_list[0].span(),
|
||||
errors::MacroExport::UnknownItem { name: meta_item_list[0].name_or_empty() },
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// special case when `#[macro_export]` is applied to a macro 2.0
|
||||
|
|
|
@ -1500,15 +1500,13 @@ impl<'tcx> Liveness<'_, 'tcx> {
|
|||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(name) = self.should_warn(var) {
|
||||
self.ir.tcx.emit_node_span_lint(
|
||||
lint::builtin::UNUSED_VARIABLES,
|
||||
var_hir_id,
|
||||
vec![span],
|
||||
errors::UnusedVarMaybeCaptureRef { name },
|
||||
);
|
||||
}
|
||||
} else if let Some(name) = self.should_warn(var) {
|
||||
self.ir.tcx.emit_node_span_lint(
|
||||
lint::builtin::UNUSED_VARIABLES,
|
||||
var_hir_id,
|
||||
vec![span],
|
||||
errors::UnusedVarMaybeCaptureRef { name },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,16 +174,14 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
|||
|
||||
// If the current node is a function, has const stability attributes and if it doesn not have an intrinsic ABI,
|
||||
// check if the function/method is const or the parent impl block is const
|
||||
if let (Some(const_span), Some(fn_sig)) = (const_span, fn_sig) {
|
||||
if fn_sig.header.abi != Abi::RustIntrinsic && !fn_sig.header.is_const() {
|
||||
if !self.in_trait_impl
|
||||
|| (self.in_trait_impl && !self.tcx.is_const_fn_raw(def_id.to_def_id()))
|
||||
{
|
||||
self.tcx
|
||||
.dcx()
|
||||
.emit_err(errors::MissingConstErr { fn_sig_span: fn_sig.span, const_span });
|
||||
}
|
||||
}
|
||||
if let (Some(const_span), Some(fn_sig)) = (const_span, fn_sig)
|
||||
&& fn_sig.header.abi != Abi::RustIntrinsic
|
||||
&& !fn_sig.header.is_const()
|
||||
&& (!self.in_trait_impl || !self.tcx.is_const_fn_raw(def_id.to_def_id()))
|
||||
{
|
||||
self.tcx
|
||||
.dcx()
|
||||
.emit_err(errors::MissingConstErr { fn_sig_span: fn_sig.span, const_span });
|
||||
}
|
||||
|
||||
// `impl const Trait for Type` items forward their const stability to their
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue