Auto merge of #115820 - matthiaskrgr:rollup-kyglvpu, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #115736 (Remove `verbose_generic_activity_with_arg`) - #115771 (cleanup leftovers of const_err lint) - #115798 (add helper method for finding the one non-1-ZST field) - #115812 (Merge settings.css into rustdoc.css) - #115815 (fix: return early when has tainted in mir pass) - #115816 (Disabled socketpair for Vita) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
eb2446a57e
25 changed files with 231 additions and 227 deletions
|
@ -4,7 +4,6 @@ use rustc_errors::{DiagnosticArgValue, DiagnosticMessage, IntoDiagnostic, IntoDi
|
|||
use rustc_middle::mir::AssertKind;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::ty::{layout::LayoutError, ConstInt};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::{ErrorGuaranteed, Span, Symbol};
|
||||
|
||||
use super::InterpCx;
|
||||
|
@ -132,7 +131,8 @@ where
|
|||
{
|
||||
// Special handling for certain errors
|
||||
match error {
|
||||
// Don't emit a new diagnostic for these errors
|
||||
// Don't emit a new diagnostic for these errors, they are already reported elsewhere or
|
||||
// should remain silent.
|
||||
err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => {
|
||||
ErrorHandled::TooGeneric
|
||||
}
|
||||
|
@ -140,27 +140,8 @@ where
|
|||
err_inval!(Layout(LayoutError::ReferencesError(guar))) => {
|
||||
ErrorHandled::Reported(guar.into())
|
||||
}
|
||||
err_inval!(Layout(layout_error @ LayoutError::SizeOverflow(_))) => {
|
||||
// We must *always* hard error on these, even if the caller wants just a lint.
|
||||
// The `message` makes little sense here, this is a more serious error than the
|
||||
// caller thinks anyway.
|
||||
// See <https://github.com/rust-lang/rust/pull/63152>.
|
||||
let (our_span, frames) = get_span_and_frames();
|
||||
let span = span.unwrap_or(our_span);
|
||||
let mut err =
|
||||
tcx.sess.create_err(Spanned { span, node: layout_error.into_diagnostic() });
|
||||
err.code(rustc_errors::error_code!(E0080));
|
||||
let Some((mut err, handler)) = err.into_diagnostic() else {
|
||||
panic!("did not emit diag");
|
||||
};
|
||||
for frame in frames {
|
||||
err.eager_subdiagnostic(handler, frame);
|
||||
}
|
||||
|
||||
ErrorHandled::Reported(handler.emit_diagnostic(&mut err).unwrap().into())
|
||||
}
|
||||
// Report remaining errors.
|
||||
_ => {
|
||||
// Report as hard error.
|
||||
let (our_span, frames) = get_span_and_frames();
|
||||
let span = span.unwrap_or(our_span);
|
||||
let err = mk(span, frames);
|
||||
|
|
|
@ -372,7 +372,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
|
|||
};
|
||||
let alloc_id = mplace.ptr().provenance.unwrap();
|
||||
|
||||
// Validation failed, report an error. This is always a hard error.
|
||||
// Validation failed, report an error.
|
||||
if let Err(error) = validation {
|
||||
let (error, backtrace) = error.into_parts();
|
||||
backtrace.print_backtrace();
|
||||
|
|
|
@ -269,19 +269,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
match layout.ty.kind() {
|
||||
ty::Adt(adt_def, _) if adt_def.repr().transparent() && may_unfold(*adt_def) => {
|
||||
assert!(!adt_def.is_enum());
|
||||
// Find the non-1-ZST field.
|
||||
let mut non_1zst_fields = (0..layout.fields.count()).filter_map(|idx| {
|
||||
let field = layout.field(self, idx);
|
||||
if field.is_1zst() { None } else { Some(field) }
|
||||
});
|
||||
let first = non_1zst_fields.next().expect("`unfold_transparent` called on 1-ZST");
|
||||
assert!(
|
||||
non_1zst_fields.next().is_none(),
|
||||
"more than one non-1-ZST field in a transparent type"
|
||||
);
|
||||
|
||||
// Found it!
|
||||
self.unfold_transparent(first, may_unfold)
|
||||
// Find the non-1-ZST field, and recurse.
|
||||
let (_, field) = layout.non_1zst_field(self).unwrap();
|
||||
self.unfold_transparent(field, may_unfold)
|
||||
}
|
||||
// Not a transparent type, no further unfolding.
|
||||
_ => layout,
|
||||
|
@ -797,25 +787,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
_ => {
|
||||
// Not there yet, search for the only non-ZST field.
|
||||
// (The rules for `DispatchFromDyn` ensure there's exactly one such field.)
|
||||
let mut non_zst_field = None;
|
||||
for i in 0..receiver.layout.fields.count() {
|
||||
let field = self.project_field(&receiver, i)?;
|
||||
let zst = field.layout.is_1zst();
|
||||
if !zst {
|
||||
assert!(
|
||||
non_zst_field.is_none(),
|
||||
"multiple non-1-ZST fields in dyn receiver type {}",
|
||||
receiver.layout.ty
|
||||
);
|
||||
non_zst_field = Some(field);
|
||||
}
|
||||
}
|
||||
receiver = non_zst_field.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"no non-1-ZST fields in dyn receiver type {}",
|
||||
receiver.layout.ty
|
||||
)
|
||||
});
|
||||
let (idx, _) = receiver.layout.non_1zst_field(self).expect(
|
||||
"not exactly one non-1-ZST field in a `DispatchFromDyn` type",
|
||||
);
|
||||
receiver = self.project_field(&receiver, idx)?;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue