Also fix if in else
This commit is contained in:
parent
954419aab0
commit
af8d911d63
27 changed files with 223 additions and 291 deletions
|
@ -1151,42 +1151,40 @@ 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![]) {
|
||||
let mut err = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0588,
|
||||
"packed type cannot transitively contain a `#[repr(align)]` type"
|
||||
);
|
||||
} else if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
||||
let mut err = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0588,
|
||||
"packed type cannot transitively contain a `#[repr(align)]` type"
|
||||
);
|
||||
|
||||
err.span_note(
|
||||
tcx.def_span(def_spans[0].0),
|
||||
format!("`{}` has a `#[repr(align)]` attribute", tcx.item_name(def_spans[0].0)),
|
||||
);
|
||||
err.span_note(
|
||||
tcx.def_span(def_spans[0].0),
|
||||
format!("`{}` has a `#[repr(align)]` attribute", tcx.item_name(def_spans[0].0)),
|
||||
);
|
||||
|
||||
if def_spans.len() > 2 {
|
||||
let mut first = true;
|
||||
for (adt_def, span) in def_spans.iter().skip(1).rev() {
|
||||
let ident = tcx.item_name(*adt_def);
|
||||
err.span_note(
|
||||
*span,
|
||||
if first {
|
||||
format!(
|
||||
"`{}` contains a field of type `{}`",
|
||||
tcx.type_of(def.did()).instantiate_identity(),
|
||||
ident
|
||||
)
|
||||
} else {
|
||||
format!("...which contains a field of type `{ident}`")
|
||||
},
|
||||
);
|
||||
first = false;
|
||||
}
|
||||
if def_spans.len() > 2 {
|
||||
let mut first = true;
|
||||
for (adt_def, span) in def_spans.iter().skip(1).rev() {
|
||||
let ident = tcx.item_name(*adt_def);
|
||||
err.span_note(
|
||||
*span,
|
||||
if first {
|
||||
format!(
|
||||
"`{}` contains a field of type `{}`",
|
||||
tcx.type_of(def.did()).instantiate_identity(),
|
||||
ident
|
||||
)
|
||||
} else {
|
||||
format!("...which contains a field of type `{ident}`")
|
||||
},
|
||||
);
|
||||
first = false;
|
||||
}
|
||||
|
||||
err.emit();
|
||||
}
|
||||
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,24 +381,22 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
|
|||
}
|
||||
|
||||
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 {
|
||||
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)
|
||||
// Fall back to the RPIT we inferred during HIR typeck
|
||||
if let Some(hir_opaque_ty) = hir_opaque_ty {
|
||||
hir_opaque_ty.ty
|
||||
} else {
|
||||
// Fall back to the RPIT we inferred during HIR typeck
|
||||
if let Some(hir_opaque_ty) = hir_opaque_ty {
|
||||
hir_opaque_ty.ty
|
||||
} else {
|
||||
// We failed to resolve the opaque type or it
|
||||
// resolves to itself. We interpret this as the
|
||||
// no values of the hidden type ever being constructed,
|
||||
// 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)
|
||||
}
|
||||
// We failed to resolve the opaque type or it
|
||||
// resolves to itself. We interpret this as the
|
||||
// no values of the hidden type ever being constructed,
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -562,13 +562,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
tcx.const_param_default(param.def_id)
|
||||
.instantiate(tcx, preceding_args)
|
||||
.into()
|
||||
} else if infer_args {
|
||||
self.lowerer.ct_infer(Some(param), self.span).into()
|
||||
} else {
|
||||
if infer_args {
|
||||
self.lowerer.ct_infer(Some(param), self.span).into()
|
||||
} else {
|
||||
// We've already errored above about the mismatch.
|
||||
ty::Const::new_misc_error(tcx).into()
|
||||
}
|
||||
// We've already errored above about the mismatch.
|
||||
ty::Const::new_misc_error(tcx).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue