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,8 +45,7 @@ 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 {
@ -58,5 +57,4 @@ pub fn entry_point_type(
} else { } else {
EntryPointType::None EntryPointType::None
} }
}
} }

View File

@ -628,14 +628,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
.map_or(Const::No, |attr| Const::Yes(attr.span)), .map_or(Const::No, |attr| Const::Yes(attr.span)),
_ => Const::No, _ => Const::No,
} }
} else { } else if self.tcx.is_const_trait(def_id) {
if self.tcx.is_const_trait(def_id) {
// FIXME(effects) span // FIXME(effects) span
Const::Yes(self.tcx.def_ident_span(def_id).unwrap()) Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
} else { } else {
Const::No Const::No
} }
}
} else { } else {
Const::No Const::No
} }

View File

@ -118,11 +118,9 @@ impl LivenessValues {
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.
if let Some(loans) = self.loans.as_mut() { if let Some(loans) = self.loans.as_mut() {
@ -137,11 +135,9 @@ impl LivenessValues {
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.
if let Some(loans) = self.loans.as_mut() { if let Some(loans) = self.loans.as_mut() {

View File

@ -234,15 +234,13 @@ 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 });
} }
} }
}
if args.options.contains(ast::InlineAsmOptions::NOMEM) if args.options.contains(ast::InlineAsmOptions::NOMEM)
&& args.options.contains(ast::InlineAsmOptions::READONLY) && args.options.contains(ast::InlineAsmOptions::READONLY)

View File

@ -281,14 +281,12 @@ 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 { } else if used_crate_source.rmeta.is_some() {
if used_crate_source.rmeta.is_some() {
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name }); return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
} else { } else {
return Err(errors::LinkRlibError::NotFound { crate_name }); return Err(errors::LinkRlibError::NotFound { crate_name });
} }
} }
}
Ok(()) Ok(())
} }
@ -628,14 +626,12 @@ 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 { } else if used_crate_source.rmeta.is_some() {
if used_crate_source.rmeta.is_some() {
sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name }); sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
} else { } else {
sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name }); sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
} }
} }
}
all_native_libs.extend_from_slice(&codegen_results.crate_info.used_libraries); all_native_libs.extend_from_slice(&codegen_results.crate_info.used_libraries);
@ -1972,11 +1968,9 @@ 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,12 +2629,10 @@ 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 } => {
if link_dynamic { if link_dynamic {
cmd.link_framework_by_name(name, verbatim, as_needed.unwrap_or(true)) cmd.link_framework_by_name(name, verbatim, as_needed.unwrap_or(true))

View File

@ -791,8 +791,7 @@ impl<'a> Linker for GccLinker<'a> {
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 { } else if is_windows {
if is_windows {
self.link_arg(path); self.link_arg(path);
} else { } else {
let mut arg = OsString::from("--version-script="); let mut arg = OsString::from("--version-script=");
@ -800,7 +799,6 @@ impl<'a> Linker for GccLinker<'a> {
self.link_arg(arg).link_arg("--no-undefined-version"); self.link_arg(arg).link_arg("--no-undefined-version");
} }
} }
}
fn subsystem(&mut self, subsystem: &str) { fn subsystem(&mut self, subsystem: &str) {
self.link_args(&["--subsystem", subsystem]); self.link_args(&["--subsystem", subsystem]);

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 { } else if trait_data.len() > 1 && auto_traits.len() != 0 {
if trait_data.len() > 1 && auto_traits.len() != 0 {
// We need enclosing parens because there is more than one trait // We need enclosing parens because there is more than one trait
output.push_str("(dyn "); output.push_str("(dyn ");
true true
} else { } else {
output.push_str("dyn "); output.push_str("dyn ");
false false
}
}; };
if let Some(principal) = trait_data.principal() { if let Some(principal) = trait_data.principal() {

View File

@ -1151,8 +1151,7 @@ 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,
@ -1188,7 +1187,6 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
err.emit(); err.emit();
} }
} }
}
} }
pub(super) fn check_packed_inner( pub(super) fn check_packed_inner(

View File

@ -381,8 +381,7 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
} }
mir_opaque_ty.ty mir_opaque_ty.ty
} else { } else if let Some(guar) = tables.tainted_by_errors {
if let Some(guar) = tables.tainted_by_errors {
// Some error in the owner fn prevented us from populating // Some error in the owner fn prevented us from populating
// the `concrete_opaque_types` table. // the `concrete_opaque_types` table.
Ty::new_error(tcx, guar) Ty::new_error(tcx, guar)
@ -400,7 +399,6 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
Ty::new_diverging_default(tcx) Ty::new_diverging_default(tcx)
} }
} }
}
} }
struct RpitConstraintChecker<'tcx> { struct RpitConstraintChecker<'tcx> {

View File

@ -562,8 +562,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
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 { } else if infer_args {
if infer_args {
self.lowerer.ct_infer(Some(param), self.span).into() self.lowerer.ct_infer(Some(param), self.span).into()
} else { } else {
// We've already errored above about the mismatch. // We've already errored above about the mismatch.
@ -573,7 +572,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
} }
} }
} }
}
if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness
&& generics.has_self && generics.has_self
&& !tcx.is_const_trait(def_id) && !tcx.is_const_trait(def_id)

View File

@ -2902,8 +2902,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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( err.span_suggestion_verbose(
field.span, field.span,
"a field with a similar name exists", "a field with a similar name exists",
@ -2912,11 +2913,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
); );
} else if !field_names.is_empty() { } else if !field_names.is_empty() {
let is = if field_names.len() == 1 { " is" } else { "s are" }; let is = if field_names.len() == 1 { " is" } else { "s are" };
err.note(format!( err.note(
"available field{is}: {}", format!("available field{is}: {}", self.name_series_display(field_names),),
self.name_series_display(field_names), );
));
}
} }
} }
err err

View File

@ -158,15 +158,13 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, '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!(
"pattern binding {} is assigned to {} with type {:?}", "pattern binding {} is assigned to {} with type {:?}",

View File

@ -417,13 +417,11 @@ 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 { } else if let Some(ident) = item.ident() {
if let Some(ident) = item.ident() {
tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident }); tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
} else { } else {
tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() }); tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
} }
}
} }
/// A visitor that collects all `#[rustc_clean]` attributes from /// A visitor that collects all `#[rustc_clean]` attributes from

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 { } else if pass_num {
if pass_num {
format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count) format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
} else { } else {
".-------".to_string() ".-------".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,8 +2554,7 @@ impl<'a> Parser<'a> {
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 { } else if let Some(block) = recover_block_from_condition(self) {
if let Some(block) = recover_block_from_condition(self) {
block block
} else { } else {
self.error_on_extra_if(&cond)?; self.error_on_extra_if(&cond)?;
@ -2592,7 +2591,6 @@ impl<'a> Parser<'a> {
} }
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 @@ impl<'a> Parser<'a> {
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 { } else if self.eat(&token::Eq) {
if self.eat(&token::Eq) {
let eq_span = self.prev_token.span; let eq_span = self.prev_token.span;
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?)) AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?))
} else { } else {
AttrArgs::Empty AttrArgs::Empty
}
}) })
} }

View File

@ -1336,8 +1336,7 @@ impl<'a> Parser<'a> {
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",
@ -1352,7 +1351,6 @@ impl<'a> Parser<'a> {
); );
} }
} }
}
err.emit(); err.emit();
} }
Ok((fields, etc)) Ok((fields, etc))

View File

@ -192,14 +192,12 @@ 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(),
}); });
} }
}
} }
// Called by `check_builtin_meta_item` and code that manually denies // Called by `check_builtin_meta_item` and code that manually denies

View File

@ -2172,18 +2172,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
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 { errors::MacroExport::UnknownItem { name: meta_item_list[0].name_or_empty() },
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
let (macro_definition, _) = self.tcx.hir_node(hir_id).expect_item().expect_macro(); let (macro_definition, _) = self.tcx.hir_node(hir_id).expect_item().expect_macro();

View File

@ -1500,8 +1500,7 @@ impl<'tcx> Liveness<'_, 'tcx> {
); );
} }
} }
} 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,
@ -1512,7 +1511,6 @@ impl<'tcx> Liveness<'_, 'tcx> {
} }
} }
} }
}
fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) { fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) {
for p in body.params { for p in body.params {

View File

@ -1256,16 +1256,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
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().create_err(CannotBeReexportedCratePublicNS {
span: import.span,
ident,
})
} else {
self.dcx() self.dcx()
.create_err(CannotBeReexportedPrivateNS { span: import.span, ident }) .create_err(CannotBeReexportedCratePublicNS { span: import.span, ident })
} else {
self.dcx().create_err(CannotBeReexportedPrivateNS { span: import.span, ident })
}; };
err.emit(); err.emit();
} else { } else {
@ -1273,8 +1269,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
self.dcx() self.dcx()
.create_err(CannotBeReexportedCratePublic { span: import.span, ident }) .create_err(CannotBeReexportedCratePublic { span: import.span, ident })
} else { } else {
self.dcx() self.dcx().create_err(CannotBeReexportedPrivate { span: import.span, ident })
.create_err(CannotBeReexportedPrivate { span: import.span, ident })
}; };
match binding.kind { match binding.kind {
@ -1296,7 +1291,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
err.emit(); err.emit();
} }
} }
}
if import.module_path.len() <= 1 { if import.module_path.len() <= 1 {
// HACK(eddyb) `lint_if_path_starts_with_module` needs at least // HACK(eddyb) `lint_if_path_starts_with_module` needs at least

View File

@ -270,14 +270,12 @@ 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 { } else if param_depth == 0 {
if param_depth == 0 {
stripped_segment.push(c); stripped_segment.push(c);
} else { } else {
latest_generics_chunk.push(c); latest_generics_chunk.push(c);
} }
} }
}
if param_depth == 0 { if param_depth == 0 {
Ok(stripped_segment) Ok(stripped_segment)

View File

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

View File

@ -69,8 +69,7 @@ where
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.
@ -93,7 +92,6 @@ where
arg.extend_integer_width_to(32); arg.extend_integer_width_to(32);
} }
} }
}
} }
pub(crate) fn compute_abi_info<'a, Ty, C>(_cx: &C, fn_abi: &mut FnAbi<'a, Ty>) pub(crate) fn compute_abi_info<'a, Ty, C>(_cx: &C, fn_abi: &mut FnAbi<'a, Ty>)

View File

@ -1323,8 +1323,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
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
{ {
@ -1340,7 +1339,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} else { } else {
label_or_note(span, terr.to_string(self.tcx)); 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 {
let (expected_label, found_label, exp_found) = match exp_found { let (expected_label, found_label, exp_found) = match exp_found {

View File

@ -3237,16 +3237,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// 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 { } else if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code { let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred);
let parent_trait_ref =
self.resolve_vars_if_possible(data.parent_trait_pred);
let nested_ty = parent_trait_ref.skip_binder().self_ty(); let nested_ty = parent_trait_ref.skip_binder().self_ty();
matches!(nested_ty.kind(), ty::Coroutine(..)) matches!(nested_ty.kind(), ty::Coroutine(..))
|| matches!(nested_ty.kind(), ty::Closure(..)) || matches!(nested_ty.kind(), ty::Closure(..))
} else { } else {
false false
}
}; };
if !is_upvar_tys_infer_tuple { if !is_upvar_tys_infer_tuple {

View File

@ -426,15 +426,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} 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 { } else if kind == ty::ClosureKind::FnOnce {
if kind == ty::ClosureKind::FnOnce {
candidates.vec.push(ClosureCandidate { is_const }); candidates.vec.push(ClosureCandidate { is_const });
} else { } else {
// This stays ambiguous until kind+upvars are determined. // This stays ambiguous until kind+upvars are determined.
candidates.ambiguous = true; candidates.ambiguous = true;
} }
} }
}
ty::Infer(ty::TyVar(_)) => { ty::Infer(ty::TyVar(_)) => {
debug!("assemble_unboxed_closure_candidates: ambiguous self-type"); debug!("assemble_unboxed_closure_candidates: ambiguous self-type");
candidates.ambiguous = true; candidates.ambiguous = true;