Also fix if in else
This commit is contained in:
parent
954419aab0
commit
af8d911d63
@ -45,8 +45,7 @@ pub fn entry_point_type(
|
||||
EntryPointType::Start
|
||||
} else if attr::contains_name(attrs, sym::rustc_main) {
|
||||
EntryPointType::RustcMainAttr
|
||||
} else {
|
||||
if let Some(name) = name
|
||||
} else if let Some(name) = name
|
||||
&& name == sym::main
|
||||
{
|
||||
if at_root {
|
||||
@ -59,4 +58,3 @@ pub fn entry_point_type(
|
||||
EntryPointType::None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -628,14 +628,12 @@ fn lower_assoc_item(
|
||||
.map_or(Const::No, |attr| Const::Yes(attr.span)),
|
||||
_ => Const::No,
|
||||
}
|
||||
} else {
|
||||
if self.tcx.is_const_trait(def_id) {
|
||||
} else if self.tcx.is_const_trait(def_id) {
|
||||
// FIXME(effects) span
|
||||
Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
|
||||
} else {
|
||||
Const::No
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Const::No
|
||||
}
|
||||
|
@ -118,11 +118,9 @@ pub(crate) fn add_location(&mut self, region: RegionVid, location: Location) {
|
||||
debug!("LivenessValues::add_location(region={:?}, location={:?})", region, location);
|
||||
if let Some(points) = &mut self.points {
|
||||
points.insert(region, point);
|
||||
} else {
|
||||
if self.elements.point_in_range(point) {
|
||||
} else if self.elements.point_in_range(point) {
|
||||
self.live_regions.as_mut().unwrap().insert(region);
|
||||
}
|
||||
}
|
||||
|
||||
// When available, record the loans flowing into this region as live at the given point.
|
||||
if let Some(loans) = self.loans.as_mut() {
|
||||
@ -137,11 +135,9 @@ pub(crate) fn add_points(&mut self, region: RegionVid, points: &IntervalSet<Poin
|
||||
debug!("LivenessValues::add_points(region={:?}, points={:?})", region, points);
|
||||
if let Some(this) = &mut self.points {
|
||||
this.union_row(region, points);
|
||||
} else {
|
||||
if points.iter().any(|point| self.elements.point_in_range(point)) {
|
||||
} else if points.iter().any(|point| self.elements.point_in_range(point)) {
|
||||
self.live_regions.as_mut().unwrap().insert(region);
|
||||
}
|
||||
}
|
||||
|
||||
// When available, record the loans flowing into this region as live at the given points.
|
||||
if let Some(loans) = self.loans.as_mut() {
|
||||
|
@ -234,15 +234,13 @@ pub fn parse_asm_args<'a>(
|
||||
continue;
|
||||
}
|
||||
args.named_args.insert(name, slot);
|
||||
} else {
|
||||
if !args.named_args.is_empty() || !args.reg_args.is_empty() {
|
||||
} else 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 explicit = args.reg_args.iter().map(|p| args.operands[p].1).collect();
|
||||
|
||||
dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if args.options.contains(ast::InlineAsmOptions::NOMEM)
|
||||
&& args.options.contains(ast::InlineAsmOptions::READONLY)
|
||||
|
@ -281,14 +281,12 @@ 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() {
|
||||
} else if used_crate_source.rmeta.is_some() {
|
||||
return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
return Err(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -628,14 +626,12 @@ 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() {
|
||||
} 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
cmd.verbatim_args(args.iter().map(Deref::deref));
|
||||
}
|
||||
} else {
|
||||
if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
|
||||
} 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,12 +2629,10 @@ fn add_native_libs_from_crate(
|
||||
if link_static {
|
||||
cmd.link_staticlib_by_name(name, verbatim, false);
|
||||
}
|
||||
} else {
|
||||
if link_dynamic {
|
||||
} else if link_dynamic {
|
||||
cmd.link_dylib_by_name(name, verbatim, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
NativeLibKind::Framework { as_needed } => {
|
||||
if link_dynamic {
|
||||
cmd.link_framework_by_name(name, verbatim, as_needed.unwrap_or(true))
|
||||
|
@ -791,8 +791,7 @@ fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[St
|
||||
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 {
|
||||
} else if is_windows {
|
||||
self.link_arg(path);
|
||||
} else {
|
||||
let mut arg = OsString::from("--version-script=");
|
||||
@ -800,7 +799,6 @@ fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType, symbols: &[St
|
||||
self.link_arg(arg).link_arg("--no-undefined-version");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn subsystem(&mut self, subsystem: &str) {
|
||||
self.link_args(&["--subsystem", subsystem]);
|
||||
|
@ -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 {
|
||||
} 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
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(principal) = trait_data.principal() {
|
||||
|
@ -1151,8 +1151,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||
"type has conflicting packed and align representation hints"
|
||||
)
|
||||
.emit();
|
||||
} else {
|
||||
if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
||||
} else if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
||||
let mut err = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
@ -1189,7 +1188,6 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn check_packed_inner(
|
||||
tcx: TyCtxt<'_>,
|
||||
|
@ -381,8 +381,7 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
|
||||
}
|
||||
|
||||
mir_opaque_ty.ty
|
||||
} else {
|
||||
if let Some(guar) = tables.tainted_by_errors {
|
||||
} 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)
|
||||
@ -401,7 +400,6 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RpitConstraintChecker<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -562,8 +562,7 @@ fn inferred_kind(
|
||||
tcx.const_param_default(param.def_id)
|
||||
.instantiate(tcx, preceding_args)
|
||||
.into()
|
||||
} else {
|
||||
if infer_args {
|
||||
} else if infer_args {
|
||||
self.lowerer.ct_infer(Some(param), self.span).into()
|
||||
} else {
|
||||
// We've already errored above about the mismatch.
|
||||
@ -573,7 +572,6 @@ fn inferred_kind(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let ty::BoundConstness::Const | ty::BoundConstness::ConstIfConst = constness
|
||||
&& generics.has_self
|
||||
&& !tcx.is_const_trait(def_id)
|
||||
|
@ -2902,8 +2902,9 @@ fn no_such_field_err(&self, field: Ident, expr_t: Ty<'tcx>, id: HirId) -> Diag<'
|
||||
candidate_fields.iter().map(|path| format!("{unwrap}{path}")),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else {
|
||||
if let Some(field_name) = find_best_match_for_name(&field_names, field.name, None) {
|
||||
} else if let Some(field_name) =
|
||||
find_best_match_for_name(&field_names, field.name, None)
|
||||
{
|
||||
err.span_suggestion_verbose(
|
||||
field.span,
|
||||
"a field with a similar name exists",
|
||||
@ -2912,11 +2913,9 @@ fn no_such_field_err(&self, field: Ident, expr_t: Ty<'tcx>, id: HirId) -> Diag<'
|
||||
);
|
||||
} else if !field_names.is_empty() {
|
||||
let is = if field_names.len() == 1 { " is" } else { "s are" };
|
||||
err.note(format!(
|
||||
"available field{is}: {}",
|
||||
self.name_series_display(field_names),
|
||||
));
|
||||
}
|
||||
err.note(
|
||||
format!("available field{is}: {}", self.name_series_display(field_names),),
|
||||
);
|
||||
}
|
||||
}
|
||||
err
|
||||
|
@ -158,15 +158,13 @@ fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) {
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if !self.fcx.tcx.features().unsized_locals {
|
||||
} else if !self.fcx.tcx.features().unsized_locals {
|
||||
self.fcx.require_type_is_sized(
|
||||
var_ty,
|
||||
p.span,
|
||||
ObligationCauseCode::VariableType(p.hir_id),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
debug!(
|
||||
"pattern binding {} is assigned to {} with type {:?}",
|
||||
|
@ -417,14 +417,12 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool {
|
||||
fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
|
||||
if let Some(value) = item.value_str() {
|
||||
value
|
||||
} else {
|
||||
if let Some(ident) = item.ident() {
|
||||
} else if let Some(ident) = item.ident() {
|
||||
tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
|
||||
} else {
|
||||
tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A visitor that collects all `#[rustc_clean]` attributes from
|
||||
/// the HIR. It is used to verify that we really ran checks for all annotated
|
||||
|
@ -208,12 +208,10 @@ fn dump_path<'tcx>(
|
||||
|
||||
let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number {
|
||||
String::new()
|
||||
} else {
|
||||
if pass_num {
|
||||
} else if pass_num {
|
||||
format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
|
||||
} else {
|
||||
".-------".to_string()
|
||||
}
|
||||
};
|
||||
|
||||
let crate_name = tcx.crate_name(source.def_id().krate);
|
||||
|
@ -2554,8 +2554,7 @@ fn parse_if_after_cond(&mut self, lo: Span, mut cond: P<Expr>) -> PResult<'a, P<
|
||||
let maybe_fatarrow = self.token.clone();
|
||||
let block = if self.check(&token::OpenDelim(Delimiter::Brace)) {
|
||||
self.parse_block()?
|
||||
} else {
|
||||
if let Some(block) = recover_block_from_condition(self) {
|
||||
} else if let Some(block) = recover_block_from_condition(self) {
|
||||
block
|
||||
} else {
|
||||
self.error_on_extra_if(&cond)?;
|
||||
@ -2592,7 +2591,6 @@ fn parse_if_after_cond(&mut self, lo: Span, mut cond: P<Expr>) -> PResult<'a, P<
|
||||
}
|
||||
err
|
||||
})?
|
||||
}
|
||||
};
|
||||
self.error_on_if_block_attrs(lo, false, block.span, attrs);
|
||||
block
|
||||
|
@ -1359,13 +1359,11 @@ fn parse_delim_args(&mut self) -> PResult<'a, P<DelimArgs>> {
|
||||
fn parse_attr_args(&mut self) -> PResult<'a, AttrArgs> {
|
||||
Ok(if let Some(args) = self.parse_delim_args_inner() {
|
||||
AttrArgs::Delimited(args)
|
||||
} else {
|
||||
if self.eat(&token::Eq) {
|
||||
} 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 {
|
||||
AttrArgs::Empty
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1336,8 +1336,7 @@ fn parse_pat_fields(&mut self) -> PResult<'a, (ThinVec<PatField>, PatFieldsRest)
|
||||
vec![(first_etc_span, String::new())],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else {
|
||||
if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span {
|
||||
} else if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span {
|
||||
// We have `.., x`.
|
||||
err.multipart_suggestion(
|
||||
"move the `..` to the end of the field list",
|
||||
@ -1352,7 +1351,6 @@ fn parse_pat_fields(&mut self) -> PResult<'a, (ThinVec<PatField>, PatFieldsRest)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
err.emit();
|
||||
}
|
||||
Ok((fields, etc))
|
||||
|
@ -192,15 +192,13 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
|
||||
} else if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
|
||||
psess.dcx().emit_err(errors::InvalidAttrUnsafe {
|
||||
span: unsafe_span,
|
||||
name: attr_item.path.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called by `check_builtin_meta_item` and code that manually denies
|
||||
// `unsafe(...)` in `cfg`
|
||||
|
@ -2172,18 +2172,14 @@ fn check_macro_export(&self, hir_id: HirId, attr: &Attribute, target: Target) {
|
||||
attr.span,
|
||||
errors::MacroExport::TooManyItems,
|
||||
);
|
||||
} else {
|
||||
if meta_item_list[0].name_or_empty() != sym::local_inner_macros {
|
||||
} 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(),
|
||||
},
|
||||
errors::MacroExport::UnknownItem { name: meta_item_list[0].name_or_empty() },
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 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();
|
||||
|
@ -1500,8 +1500,7 @@ fn warn_about_unused_upvars(&self, entry_ln: LiveNode) {
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(name) = self.should_warn(var) {
|
||||
} else if let Some(name) = self.should_warn(var) {
|
||||
self.ir.tcx.emit_node_span_lint(
|
||||
lint::builtin::UNUSED_VARIABLES,
|
||||
var_hir_id,
|
||||
@ -1512,7 +1511,6 @@ fn warn_about_unused_upvars(&self, entry_ln: LiveNode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) {
|
||||
for p in body.params {
|
||||
|
@ -1256,16 +1256,12 @@ fn finalize_import(&mut self, import: Import<'a>) -> Option<UnresolvedImportErro
|
||||
extern_crate_span: self.tcx.source_span(self.local_def_id(extern_crate_id)),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
if ns == TypeNS {
|
||||
} else if ns == TypeNS {
|
||||
let err = if crate_private_reexport {
|
||||
self.dcx().create_err(CannotBeReexportedCratePublicNS {
|
||||
span: import.span,
|
||||
ident,
|
||||
})
|
||||
} else {
|
||||
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();
|
||||
} else {
|
||||
@ -1273,8 +1269,7 @@ fn finalize_import(&mut self, import: Import<'a>) -> Option<UnresolvedImportErro
|
||||
self.dcx()
|
||||
.create_err(CannotBeReexportedCratePublic { span: import.span, ident })
|
||||
} else {
|
||||
self.dcx()
|
||||
.create_err(CannotBeReexportedPrivate { span: import.span, ident })
|
||||
self.dcx().create_err(CannotBeReexportedPrivate { span: import.span, ident })
|
||||
};
|
||||
|
||||
match binding.kind {
|
||||
@ -1296,7 +1291,6 @@ fn finalize_import(&mut self, import: Import<'a>) -> Option<UnresolvedImportErro
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if import.module_path.len() <= 1 {
|
||||
// HACK(eddyb) `lint_if_path_starts_with_module` needs at least
|
||||
|
@ -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.
|
||||
return Err(MalformedGenerics::HasFullyQualifiedSyntax);
|
||||
}
|
||||
} else {
|
||||
if param_depth == 0 {
|
||||
} else if param_depth == 0 {
|
||||
stripped_segment.push(c);
|
||||
} else {
|
||||
latest_generics_chunk.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if param_depth == 0 {
|
||||
Ok(stripped_segment)
|
||||
|
@ -207,15 +207,13 @@ fn encode_fnsig<'tcx>(
|
||||
if fn_sig.c_variadic {
|
||||
s.push('z');
|
||||
}
|
||||
} else {
|
||||
if fn_sig.c_variadic {
|
||||
} else if fn_sig.c_variadic {
|
||||
s.push('z');
|
||||
} else {
|
||||
// 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
|
||||
s.push('E');
|
||||
|
@ -69,8 +69,7 @@ fn classify_arg_ty<'a, Ty, C>(arg: &mut ArgAbi<'_, Ty>, arg_gprs_left: &mut u64,
|
||||
|
||||
if must_use_stack {
|
||||
arg.make_indirect_byval(None);
|
||||
} else {
|
||||
if is_xtensa_aggregate(arg) {
|
||||
} else if is_xtensa_aggregate(arg) {
|
||||
// Aggregates which are <= max_size will be passed in
|
||||
// registers if possible, so coerce to integers.
|
||||
|
||||
@ -94,7 +93,6 @@ fn classify_arg_ty<'a, Ty, C>(arg: &mut ArgAbi<'_, Ty>, arg_gprs_left: &mut u64,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn compute_abi_info<'a, Ty, C>(_cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
|
||||
where
|
||||
|
@ -1323,8 +1323,7 @@ enum Mismatch<'a> {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
label_or_note(sp, msg);
|
||||
}
|
||||
} else {
|
||||
if let Some(values) = values
|
||||
} else if let Some(values) = values
|
||||
&& let Some((e, f)) = values.ty()
|
||||
&& let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
|
||||
{
|
||||
@ -1340,7 +1339,6 @@ enum Mismatch<'a> {
|
||||
} else {
|
||||
label_or_note(span, terr.to_string(self.tcx));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some((expected, found, path)) = expected_found {
|
||||
let (expected_label, found_label, exp_found) = match exp_found {
|
||||
|
@ -3237,16 +3237,13 @@ pub(super) fn note_obligation_cause_code<G: EmissionGuarantee, T>(
|
||||
// then the tuple must be the one containing capture types.
|
||||
let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) {
|
||||
false
|
||||
} else {
|
||||
if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
|
||||
let parent_trait_ref =
|
||||
self.resolve_vars_if_possible(data.parent_trait_pred);
|
||||
} 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 {
|
||||
false
|
||||
}
|
||||
};
|
||||
|
||||
if !is_upvar_tys_infer_tuple {
|
||||
|
@ -426,15 +426,13 @@ fn assemble_closure_candidates(
|
||||
} else if kind == ty::ClosureKind::FnOnce {
|
||||
candidates.vec.push(ClosureCandidate { is_const });
|
||||
}
|
||||
} else {
|
||||
if kind == ty::ClosureKind::FnOnce {
|
||||
} else if kind == ty::ClosureKind::FnOnce {
|
||||
candidates.vec.push(ClosureCandidate { is_const });
|
||||
} else {
|
||||
// This stays ambiguous until kind+upvars are determined.
|
||||
candidates.ambiguous = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
debug!("assemble_unboxed_closure_candidates: ambiguous self-type");
|
||||
candidates.ambiguous = true;
|
||||
|
Loading…
Reference in New Issue
Block a user