Simplify some nested if statements
This commit is contained in:
parent
5a2dd7d4f3
commit
954419aab0
36 changed files with 340 additions and 380 deletions
|
@ -186,17 +186,15 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
|
|||
|
||||
if let Ok(alloc) = tcx.eval_static_initializer(id.to_def_id())
|
||||
&& alloc.inner().provenance().ptrs().len() != 0
|
||||
{
|
||||
if attrs
|
||||
&& attrs
|
||||
.link_section
|
||||
.map(|link_section| !link_section.as_str().starts_with(".init_array"))
|
||||
.unwrap()
|
||||
{
|
||||
let msg = "statics with a custom `#[link_section]` must be a \
|
||||
{
|
||||
let msg = "statics with a custom `#[link_section]` must be a \
|
||||
simple list of bytes on the wasm target with no \
|
||||
extra levels of indirection such as references";
|
||||
tcx.dcx().span_err(tcx.def_span(id), msg);
|
||||
}
|
||||
tcx.dcx().span_err(tcx.def_span(id), msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,17 +53,15 @@ fn enforce_trait_manually_implementable(
|
|||
) -> Result<(), ErrorGuaranteed> {
|
||||
let impl_header_span = tcx.def_span(impl_def_id);
|
||||
|
||||
if tcx.is_lang_item(trait_def_id, LangItem::Freeze) {
|
||||
if !tcx.features().freeze_impls {
|
||||
feature_err(
|
||||
&tcx.sess,
|
||||
sym::freeze_impls,
|
||||
impl_header_span,
|
||||
"explicit impls for the `Freeze` trait are not permitted",
|
||||
)
|
||||
.with_span_label(impl_header_span, format!("impl of `Freeze` not allowed"))
|
||||
.emit();
|
||||
}
|
||||
if tcx.is_lang_item(trait_def_id, LangItem::Freeze) && !tcx.features().freeze_impls {
|
||||
feature_err(
|
||||
&tcx.sess,
|
||||
sym::freeze_impls,
|
||||
impl_header_span,
|
||||
"explicit impls for the `Freeze` trait are not permitted",
|
||||
)
|
||||
.with_span_label(impl_header_span, format!("impl of `Freeze` not allowed"))
|
||||
.emit();
|
||||
}
|
||||
|
||||
// Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]`
|
||||
|
|
|
@ -827,20 +827,18 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
|
||||
if num_generic_args_supplied_to_trait + num_assoc_fn_excess_args
|
||||
== num_trait_generics_except_self
|
||||
&& let Some(span) = self.gen_args.span_ext()
|
||||
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
|
||||
{
|
||||
if let Some(span) = self.gen_args.span_ext()
|
||||
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
|
||||
{
|
||||
let sugg = vec![
|
||||
(
|
||||
self.path_segment.ident.span,
|
||||
format!("{}::{}", snippet, self.path_segment.ident),
|
||||
),
|
||||
(span.with_lo(self.path_segment.ident.span.hi()), "".to_owned()),
|
||||
];
|
||||
let sugg = vec![
|
||||
(
|
||||
self.path_segment.ident.span,
|
||||
format!("{}::{}", snippet, self.path_segment.ident),
|
||||
),
|
||||
(span.with_lo(self.path_segment.ident.span.hi()), "".to_owned()),
|
||||
];
|
||||
|
||||
err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
|
||||
}
|
||||
err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue