Also fix if in else

This commit is contained in:
Michael Goulet 2024-09-11 17:23:56 -04:00
parent 954419aab0
commit af8d911d63
27 changed files with 223 additions and 291 deletions

View File

@ -45,18 +45,16 @@ pub fn entry_point_type(
EntryPointType::Start EntryPointType::Start
} else if attr::contains_name(attrs, sym::rustc_main) { } else if attr::contains_name(attrs, sym::rustc_main) {
EntryPointType::RustcMainAttr EntryPointType::RustcMainAttr
} else { } else if let Some(name) = name
if let Some(name) = name && name == sym::main
&& name == sym::main {
{ if at_root {
if at_root { // This is a top-level function so it can be `main`.
// This is a top-level function so it can be `main`. EntryPointType::MainNamed
EntryPointType::MainNamed
} else {
EntryPointType::OtherMain
}
} else { } else {
EntryPointType::None EntryPointType::OtherMain
} }
} else {
EntryPointType::None
} }
} }

View File

@ -628,13 +628,11 @@ fn lower_assoc_item(
.map_or(Const::No, |attr| Const::Yes(attr.span)), .map_or(Const::No, |attr| Const::Yes(attr.span)),
_ => Const::No, _ => Const::No,
} }
} else if self.tcx.is_const_trait(def_id) {
// FIXME(effects) span
Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
} else { } else {
if self.tcx.is_const_trait(def_id) { Const::No
// FIXME(effects) span
Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
} else {
Const::No
}
} }
} else { } else {
Const::No Const::No

View File

@ -118,10 +118,8 @@ pub(crate) fn add_location(&mut self, region: RegionVid, location: Location) {
debug!("LivenessValues::add_location(region={:?}, location={:?})", region, location); debug!("LivenessValues::add_location(region={:?}, location={:?})", region, location);
if let Some(points) = &mut self.points { if let Some(points) = &mut self.points {
points.insert(region, point); points.insert(region, point);
} else { } else if self.elements.point_in_range(point) {
if self.elements.point_in_range(point) { self.live_regions.as_mut().unwrap().insert(region);
self.live_regions.as_mut().unwrap().insert(region);
}
} }
// When available, record the loans flowing into this region as live at the given point. // When available, record the loans flowing into this region as live at the given point.
@ -137,10 +135,8 @@ pub(crate) fn add_points(&mut self, region: RegionVid, points: &IntervalSet<Poin
debug!("LivenessValues::add_points(region={:?}, points={:?})", region, points); debug!("LivenessValues::add_points(region={:?}, points={:?})", region, points);
if let Some(this) = &mut self.points { if let Some(this) = &mut self.points {
this.union_row(region, points); this.union_row(region, points);
} else { } else if points.iter().any(|point| self.elements.point_in_range(point)) {
if points.iter().any(|point| self.elements.point_in_range(point)) { self.live_regions.as_mut().unwrap().insert(region);
self.live_regions.as_mut().unwrap().insert(region);
}
} }
// When available, record the loans flowing into this region as live at the given points. // When available, record the loans flowing into this region as live at the given points.

View File

@ -234,13 +234,11 @@ pub fn parse_asm_args<'a>(
continue; continue;
} }
args.named_args.insert(name, slot); args.named_args.insert(name, slot);
} else { } else if !args.named_args.is_empty() || !args.reg_args.is_empty() {
if !args.named_args.is_empty() || !args.reg_args.is_empty() { let named = args.named_args.values().map(|p| args.operands[*p].1).collect();
let named = args.named_args.values().map(|p| args.operands[*p].1).collect(); let explicit = args.reg_args.iter().map(|p| args.operands[p].1).collect();
let explicit = args.reg_args.iter().map(|p| args.operands[p].1).collect();
dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit }); dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit });
}
} }
} }

View File

@ -281,12 +281,10 @@ pub fn each_linked_rlib(
let used_crate_source = &info.used_crate_source[&cnum]; let used_crate_source = &info.used_crate_source[&cnum];
if let Some((path, _)) = &used_crate_source.rlib { if let Some((path, _)) = &used_crate_source.rlib {
f(cnum, path); f(cnum, path);
} else if used_crate_source.rmeta.is_some() {
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
} else { } else {
if used_crate_source.rmeta.is_some() { return Err(errors::LinkRlibError::NotFound { crate_name });
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
} else {
return Err(errors::LinkRlibError::NotFound { crate_name });
}
} }
} }
Ok(()) Ok(())
@ -628,12 +626,10 @@ fn link_staticlib(
let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum]; let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum];
if let Some((path, _)) = &used_crate_source.dylib { if let Some((path, _)) = &used_crate_source.dylib {
all_rust_dylibs.push(&**path); all_rust_dylibs.push(&**path);
} else if used_crate_source.rmeta.is_some() {
sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
} else { } else {
if used_crate_source.rmeta.is_some() { sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
} else {
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) { if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) {
cmd.verbatim_args(args.iter().map(Deref::deref)); cmd.verbatim_args(args.iter().map(Deref::deref));
} }
} else { } else if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
if let Some(args) = sess.target.late_link_args_static.get(&flavor) { cmd.verbatim_args(args.iter().map(Deref::deref));
cmd.verbatim_args(args.iter().map(Deref::deref));
}
} }
if let Some(args) = sess.target.late_link_args.get(&flavor) { if let Some(args) = sess.target.late_link_args.get(&flavor) {
cmd.verbatim_args(args.iter().map(Deref::deref)); cmd.verbatim_args(args.iter().map(Deref::deref));
@ -2635,10 +2629,8 @@ fn add_native_libs_from_crate(
if link_static { if link_static {
cmd.link_staticlib_by_name(name, verbatim, false); cmd.link_staticlib_by_name(name, verbatim, false);
} }
} else { } else if link_dynamic {
if link_dynamic { cmd.link_dylib_by_name(name, verbatim, true);
cmd.link_dylib_by_name(name, verbatim, true);
}
} }
} }
NativeLibKind::Framework { as_needed } => { NativeLibKind::Framework { as_needed } => {

View File

@ -791,14 +791,12 @@ fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[St
self.link_arg("-exported_symbols_list").link_arg(path); self.link_arg("-exported_symbols_list").link_arg(path);
} else if self.sess.target.is_like_solaris { } else if self.sess.target.is_like_solaris {
self.link_arg("-M").link_arg(path); self.link_arg("-M").link_arg(path);
} else if is_windows {
self.link_arg(path);
} else { } else {
if is_windows { let mut arg = OsString::from("--version-script=");
self.link_arg(path); arg.push(path);
} else { 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");
}
} }
} }

View File

@ -236,15 +236,13 @@ fn push_debuginfo_type_name<'tcx>(
let has_enclosing_parens = if cpp_like_debuginfo { let has_enclosing_parens = if cpp_like_debuginfo {
output.push_str("dyn$<"); output.push_str("dyn$<");
false 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 { } else {
if trait_data.len() > 1 && auto_traits.len() != 0 { output.push_str("dyn ");
// We need enclosing parens because there is more than one trait false
output.push_str("(dyn ");
true
} else {
output.push_str("dyn ");
false
}
}; };
if let Some(principal) = trait_data.principal() { if let Some(principal) = trait_data.principal() {

View File

@ -1151,42 +1151,40 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
"type has conflicting packed and align representation hints" "type has conflicting packed and align representation hints"
) )
.emit(); .emit();
} else { } else if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) { let mut err = struct_span_code_err!(
let mut err = struct_span_code_err!( tcx.dcx(),
tcx.dcx(), sp,
sp, E0588,
E0588, "packed type cannot transitively contain a `#[repr(align)]` type"
"packed type cannot transitively contain a `#[repr(align)]` type" );
);
err.span_note( err.span_note(
tcx.def_span(def_spans[0].0), tcx.def_span(def_spans[0].0),
format!("`{}` has a `#[repr(align)]` attribute", tcx.item_name(def_spans[0].0)), format!("`{}` has a `#[repr(align)]` attribute", tcx.item_name(def_spans[0].0)),
); );
if def_spans.len() > 2 { if def_spans.len() > 2 {
let mut first = true; let mut first = true;
for (adt_def, span) in def_spans.iter().skip(1).rev() { for (adt_def, span) in def_spans.iter().skip(1).rev() {
let ident = tcx.item_name(*adt_def); let ident = tcx.item_name(*adt_def);
err.span_note( err.span_note(
*span, *span,
if first { if first {
format!( format!(
"`{}` contains a field of type `{}`", "`{}` contains a field of type `{}`",
tcx.type_of(def.did()).instantiate_identity(), tcx.type_of(def.did()).instantiate_identity(),
ident ident
) )
} else { } else {
format!("...which contains a field of type `{ident}`") format!("...which contains a field of type `{ident}`")
}, },
); );
first = false; first = false;
}
} }
err.emit();
} }
err.emit();
} }
} }
} }

View File

@ -381,24 +381,22 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
} }
mir_opaque_ty.ty mir_opaque_ty.ty
} else if let Some(guar) = tables.tainted_by_errors {
// Some error in the owner fn prevented us from populating
// the `concrete_opaque_types` table.
Ty::new_error(tcx, guar)
} else { } else {
if let Some(guar) = tables.tainted_by_errors { // Fall back to the RPIT we inferred during HIR typeck
// Some error in the owner fn prevented us from populating if let Some(hir_opaque_ty) = hir_opaque_ty {
// the `concrete_opaque_types` table. hir_opaque_ty.ty
Ty::new_error(tcx, guar)
} else { } else {
// Fall back to the RPIT we inferred during HIR typeck // We failed to resolve the opaque type or it
if let Some(hir_opaque_ty) = hir_opaque_ty { // resolves to itself. We interpret this as the
hir_opaque_ty.ty // no values of the hidden type ever being constructed,
} else { // so we can just make the hidden type be `!`.
// We failed to resolve the opaque type or it // For backwards compatibility reasons, we fall back to
// resolves to itself. We interpret this as the // `()` until we the diverging default is changed.
// no values of the hidden type ever being constructed, Ty::new_diverging_default(tcx)
// so we can just make the hidden type be `!`.
// For backwards compatibility reasons, we fall back to
// `()` until we the diverging default is changed.
Ty::new_diverging_default(tcx)
}
} }
} }
} }

View File

@ -562,13 +562,11 @@ fn inferred_kind(
tcx.const_param_default(param.def_id) tcx.const_param_default(param.def_id)
.instantiate(tcx, preceding_args) .instantiate(tcx, preceding_args)
.into() .into()
} else if infer_args {
self.lowerer.ct_infer(Some(param), self.span).into()
} else { } else {
if infer_args { // We've already errored above about the mismatch.
self.lowerer.ct_infer(Some(param), self.span).into() ty::Const::new_misc_error(tcx).into()
} else {
// We've already errored above about the mismatch.
ty::Const::new_misc_error(tcx).into()
}
} }
} }
} }

View File

@ -2902,21 +2902,20 @@ fn no_such_field_err(&self, field: Ident, expr_t: Ty<'tcx>, id: HirId) -> Diag<'
candidate_fields.iter().map(|path| format!("{unwrap}{path}")), candidate_fields.iter().map(|path| format!("{unwrap}{path}")),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} else { } else if let Some(field_name) =
if let Some(field_name) = find_best_match_for_name(&field_names, field.name, None) { find_best_match_for_name(&field_names, field.name, None)
err.span_suggestion_verbose( {
field.span, err.span_suggestion_verbose(
"a field with a similar name exists", field.span,
format!("{unwrap}{}", field_name), "a field with a similar name exists",
Applicability::MaybeIncorrect, format!("{unwrap}{}", field_name),
); Applicability::MaybeIncorrect,
} else if !field_names.is_empty() { );
let is = if field_names.len() == 1 { " is" } else { "s are" }; } else if !field_names.is_empty() {
err.note(format!( let is = if field_names.len() == 1 { " is" } else { "s are" };
"available field{is}: {}", err.note(
self.name_series_display(field_names), format!("available field{is}: {}", self.name_series_display(field_names),),
)); );
}
} }
} }
err err

View File

@ -158,14 +158,12 @@ fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
), ),
); );
} }
} else { } else if !self.fcx.tcx.features().unsized_locals {
if !self.fcx.tcx.features().unsized_locals { self.fcx.require_type_is_sized(
self.fcx.require_type_is_sized( var_ty,
var_ty, p.span,
p.span, ObligationCauseCode::VariableType(p.hir_id),
ObligationCauseCode::VariableType(p.hir_id), );
);
}
} }
debug!( debug!(

View File

@ -417,12 +417,10 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool {
fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol { fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
if let Some(value) = item.value_str() { if let Some(value) = item.value_str() {
value value
} else if let Some(ident) = item.ident() {
tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
} else { } else {
if let Some(ident) = item.ident() { tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
} else {
tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
}
} }
} }

View File

@ -208,12 +208,10 @@ fn dump_path<'tcx>(
let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number { let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number {
String::new() String::new()
} else if pass_num {
format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
} else { } else {
if pass_num { ".-------".to_string()
format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
} else {
".-------".to_string()
}
}; };
let crate_name = tcx.crate_name(source.def_id().krate); let crate_name = tcx.crate_name(source.def_id().krate);

View File

@ -2554,13 +2554,12 @@ fn parse_if_after_cond(&mut self, lo: Span, mut cond: P<Expr>) -> PResult<'a, P<
let maybe_fatarrow = self.token.clone(); let maybe_fatarrow = self.token.clone();
let block = if self.check(&token::OpenDelim(Delimiter::Brace)) { let block = if self.check(&token::OpenDelim(Delimiter::Brace)) {
self.parse_block()? self.parse_block()?
} else if let Some(block) = recover_block_from_condition(self) {
block
} else { } else {
if let Some(block) = recover_block_from_condition(self) { self.error_on_extra_if(&cond)?;
block // Parse block, which will always fail, but we can add a nice note to the error
} else { self.parse_block().map_err(|mut err| {
self.error_on_extra_if(&cond)?;
// Parse block, which will always fail, but we can add a nice note to the error
self.parse_block().map_err(|mut err| {
if self.prev_token == token::Semi if self.prev_token == token::Semi
&& self.token == token::AndAnd && self.token == token::AndAnd
&& let maybe_let = self.look_ahead(1, |t| t.clone()) && let maybe_let = self.look_ahead(1, |t| t.clone())
@ -2592,7 +2591,6 @@ fn parse_if_after_cond(&mut self, lo: Span, mut cond: P<Expr>) -> PResult<'a, P<
} }
err err
})? })?
}
}; };
self.error_on_if_block_attrs(lo, false, block.span, attrs); self.error_on_if_block_attrs(lo, false, block.span, attrs);
block block

View File

@ -1359,13 +1359,11 @@ fn parse_delim_args(&mut self) -> PResult<'a, P<DelimArgs>> {
fn parse_attr_args(&mut self) -> PResult<'a, AttrArgs> { fn parse_attr_args(&mut self) -> PResult<'a, AttrArgs> {
Ok(if let Some(args) = self.parse_delim_args_inner() { Ok(if let Some(args) = self.parse_delim_args_inner() {
AttrArgs::Delimited(args) AttrArgs::Delimited(args)
} else if self.eat(&token::Eq) {
let eq_span = self.prev_token.span;
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?))
} else { } else {
if self.eat(&token::Eq) { AttrArgs::Empty
let eq_span = self.prev_token.span;
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?))
} else {
AttrArgs::Empty
}
}) })
} }

View File

@ -1336,21 +1336,19 @@ fn parse_pat_fields(&mut self) -> PResult<'a, (ThinVec<PatField>, PatFieldsRest)
vec![(first_etc_span, String::new())], vec![(first_etc_span, String::new())],
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else { } else if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span {
if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span { // We have `.., x`.
// We have `.., x`. err.multipart_suggestion(
err.multipart_suggestion( "move the `..` to the end of the field list",
"move the `..` to the end of the field list", vec![
vec![ (first_etc_span, String::new()),
(first_etc_span, String::new()), (
( self.token.span.to(last_non_comma_dotdot_span.shrink_to_hi()),
self.token.span.to(last_non_comma_dotdot_span.shrink_to_hi()), format!("{} .. }}", if ate_comma { "" } else { "," }),
format!("{} .. }}", if ate_comma { "" } else { "," }), ),
), ],
], Applicability::MachineApplicable,
Applicability::MachineApplicable, );
);
}
} }
} }
err.emit(); err.emit();

View File

@ -192,13 +192,11 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
); );
} }
} }
} else { } else if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
if let Safety::Unsafe(unsafe_span) = attr_item.unsafety { psess.dcx().emit_err(errors::InvalidAttrUnsafe {
psess.dcx().emit_err(errors::InvalidAttrUnsafe { span: unsafe_span,
span: unsafe_span, name: attr_item.path.clone(),
name: attr_item.path.clone(), });
});
}
} }
} }

View File

@ -2172,17 +2172,13 @@ fn check_macro_export(&self, hir_id: HirId, attr: &Attribute, target: Target) {
attr.span, attr.span,
errors::MacroExport::TooManyItems, errors::MacroExport::TooManyItems,
); );
} else { } else if meta_item_list[0].name_or_empty() != sym::local_inner_macros {
if meta_item_list[0].name_or_empty() != sym::local_inner_macros { self.tcx.emit_node_span_lint(
self.tcx.emit_node_span_lint( INVALID_MACRO_EXPORT_ARGUMENTS,
INVALID_MACRO_EXPORT_ARGUMENTS, hir_id,
hir_id, meta_item_list[0].span(),
meta_item_list[0].span(), errors::MacroExport::UnknownItem { name: meta_item_list[0].name_or_empty() },
errors::MacroExport::UnknownItem { );
name: meta_item_list[0].name_or_empty(),
},
);
}
} }
} else { } else {
// special case when `#[macro_export]` is applied to a macro 2.0 // special case when `#[macro_export]` is applied to a macro 2.0

View File

@ -1500,15 +1500,13 @@ fn warn_about_unused_upvars(&self, entry_ln: LiveNode) {
); );
} }
} }
} else { } else if let Some(name) = self.should_warn(var) {
if let Some(name) = self.should_warn(var) { self.ir.tcx.emit_node_span_lint(
self.ir.tcx.emit_node_span_lint( lint::builtin::UNUSED_VARIABLES,
lint::builtin::UNUSED_VARIABLES, var_hir_id,
var_hir_id, vec![span],
vec![span], errors::UnusedVarMaybeCaptureRef { name },
errors::UnusedVarMaybeCaptureRef { name }, );
);
}
} }
} }
} }

View File

@ -1256,28 +1256,23 @@ fn finalize_import(&mut self, import: Import<'a>) -> Option<UnresolvedImportErro
extern_crate_span: self.tcx.source_span(self.local_def_id(extern_crate_id)), extern_crate_span: self.tcx.source_span(self.local_def_id(extern_crate_id)),
}, },
); );
} else { } else if ns == TypeNS {
if ns == TypeNS { let err = if crate_private_reexport {
let err = if crate_private_reexport { self.dcx()
self.dcx().create_err(CannotBeReexportedCratePublicNS { .create_err(CannotBeReexportedCratePublicNS { span: import.span, ident })
span: import.span,
ident,
})
} else {
self.dcx()
.create_err(CannotBeReexportedPrivateNS { span: import.span, ident })
};
err.emit();
} else { } else {
let mut err = if crate_private_reexport { self.dcx().create_err(CannotBeReexportedPrivateNS { span: import.span, ident })
self.dcx() };
.create_err(CannotBeReexportedCratePublic { span: import.span, ident }) err.emit();
} else { } else {
self.dcx() let mut err = if crate_private_reexport {
.create_err(CannotBeReexportedPrivate { span: import.span, ident }) self.dcx()
}; .create_err(CannotBeReexportedCratePublic { span: import.span, ident })
} else {
self.dcx().create_err(CannotBeReexportedPrivate { span: import.span, ident })
};
match binding.kind { match binding.kind {
NameBindingKind::Res(Res::Def(DefKind::Macro(_), def_id)) NameBindingKind::Res(Res::Def(DefKind::Macro(_), def_id))
// exclude decl_macro // exclude decl_macro
if self.get_macro_by_def_id(def_id).macro_rules => if self.get_macro_by_def_id(def_id).macro_rules =>
@ -1293,8 +1288,7 @@ fn finalize_import(&mut self, import: Import<'a>) -> Option<UnresolvedImportErro
}); });
} }
} }
err.emit(); err.emit();
}
} }
} }

View File

@ -270,12 +270,10 @@ fn strip_generics_from_path_segment(segment: Vec<char>) -> Result<String, Malfor
// Give a helpful error message instead of completely ignoring the angle brackets. // Give a helpful error message instead of completely ignoring the angle brackets.
return Err(MalformedGenerics::HasFullyQualifiedSyntax); return Err(MalformedGenerics::HasFullyQualifiedSyntax);
} }
} else if param_depth == 0 {
stripped_segment.push(c);
} else { } else {
if param_depth == 0 { latest_generics_chunk.push(c);
stripped_segment.push(c);
} else {
latest_generics_chunk.push(c);
}
} }
} }

View File

@ -207,14 +207,12 @@ fn encode_fnsig<'tcx>(
if fn_sig.c_variadic { if fn_sig.c_variadic {
s.push('z'); s.push('z');
} }
} else if fn_sig.c_variadic {
s.push('z');
} else { } else {
if fn_sig.c_variadic { // Empty parameter lists, whether declared as () or conventionally as (void), are
s.push('z'); // encoded with a void parameter specifier "v".
} else { s.push('v')
// Empty parameter lists, whether declared as () or conventionally as (void), are
// encoded with a void parameter specifier "v".
s.push('v')
}
} }
// Close the "F..E" pair // Close the "F..E" pair

View File

@ -69,29 +69,27 @@ fn classify_arg_ty<'a, Ty, C>(arg: &mut ArgAbi<'_, Ty>, arg_gprs_left: &mut u64,
if must_use_stack { if must_use_stack {
arg.make_indirect_byval(None); arg.make_indirect_byval(None);
} else { } else if is_xtensa_aggregate(arg) {
if is_xtensa_aggregate(arg) { // Aggregates which are <= max_size will be passed in
// Aggregates which are <= max_size will be passed in // registers if possible, so coerce to integers.
// registers if possible, so coerce to integers.
// Use a single `xlen` int if possible, 2 * `xlen` if 2 * `xlen` alignment // Use a single `xlen` int if possible, 2 * `xlen` if 2 * `xlen` alignment
// is required, and a 2-element `xlen` array if only `xlen` alignment is // is required, and a 2-element `xlen` array if only `xlen` alignment is
// required. // required.
if size <= 32 { if size <= 32 {
arg.cast_to(Reg::i32()); arg.cast_to(Reg::i32());
} else {
let reg = if needed_align == 2 * 32 { Reg::i64() } else { Reg::i32() };
let total = Size::from_bits(((size + 32 - 1) / 32) * 32);
arg.cast_to(Uniform::new(reg, total));
}
} else { } else {
// All integral types are promoted to `xlen` let reg = if needed_align == 2 * 32 { Reg::i64() } else { Reg::i32() };
// width. let total = Size::from_bits(((size + 32 - 1) / 32) * 32);
// arg.cast_to(Uniform::new(reg, total));
// We let the LLVM backend handle integral types >= xlen. }
if size < 32 { } else {
arg.extend_integer_width_to(32); // All integral types are promoted to `xlen`
} // width.
//
// We let the LLVM backend handle integral types >= xlen.
if size < 32 {
arg.extend_integer_width_to(32);
} }
} }
} }

View File

@ -1323,23 +1323,21 @@ enum Mismatch<'a> {
label_or_note(span, terr.to_string(self.tcx)); label_or_note(span, terr.to_string(self.tcx));
label_or_note(sp, msg); label_or_note(sp, msg);
} }
} else { } else if let Some(values) = values
if let Some(values) = values && let Some((e, f)) = values.ty()
&& let Some((e, f)) = values.ty() && let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
&& let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr {
{ let e = self.tcx.erase_regions(e);
let e = self.tcx.erase_regions(e); let f = self.tcx.erase_regions(f);
let f = self.tcx.erase_regions(f); let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx));
let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx)); let found = with_forced_trimmed_paths!(f.sort_string(self.tcx));
let found = with_forced_trimmed_paths!(f.sort_string(self.tcx)); if expected == found {
if expected == found {
label_or_note(span, terr.to_string(self.tcx));
} else {
label_or_note(span, Cow::from(format!("expected {expected}, found {found}")));
}
} else {
label_or_note(span, terr.to_string(self.tcx)); label_or_note(span, terr.to_string(self.tcx));
} else {
label_or_note(span, Cow::from(format!("expected {expected}, found {found}")));
} }
} else {
label_or_note(span, terr.to_string(self.tcx));
} }
if let Some((expected, found, path)) = expected_found { if let Some((expected, found, path)) = expected_found {

View File

@ -3237,16 +3237,13 @@ pub(super) fn note_obligation_cause_code<G: EmissionGuarantee, T>(
// then the tuple must be the one containing capture types. // then the tuple must be the one containing capture types.
let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) { let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) {
false false
} else if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred);
let nested_ty = parent_trait_ref.skip_binder().self_ty();
matches!(nested_ty.kind(), ty::Coroutine(..))
|| matches!(nested_ty.kind(), ty::Closure(..))
} else { } else {
if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code { false
let parent_trait_ref =
self.resolve_vars_if_possible(data.parent_trait_pred);
let nested_ty = parent_trait_ref.skip_binder().self_ty();
matches!(nested_ty.kind(), ty::Coroutine(..))
|| matches!(nested_ty.kind(), ty::Closure(..))
} else {
false
}
}; };
if !is_upvar_tys_infer_tuple { if !is_upvar_tys_infer_tuple {

View File

@ -426,13 +426,11 @@ fn assemble_closure_candidates(
} else if kind == ty::ClosureKind::FnOnce { } else if kind == ty::ClosureKind::FnOnce {
candidates.vec.push(ClosureCandidate { is_const }); candidates.vec.push(ClosureCandidate { is_const });
} }
} else if kind == ty::ClosureKind::FnOnce {
candidates.vec.push(ClosureCandidate { is_const });
} else { } else {
if kind == ty::ClosureKind::FnOnce { // This stays ambiguous until kind+upvars are determined.
candidates.vec.push(ClosureCandidate { is_const }); candidates.ambiguous = true;
} else {
// This stays ambiguous until kind+upvars are determined.
candidates.ambiguous = true;
}
} }
} }
ty::Infer(ty::TyVar(_)) => { ty::Infer(ty::TyVar(_)) => {