diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs
index fee7287951d0a..cc21a18af3a09 100644
--- a/compiler/rustc_const_eval/src/const_eval/error.rs
+++ b/compiler/rustc_const_eval/src/const_eval/error.rs
@@ -140,7 +140,7 @@ where
// Don't emit a new diagnostic for these errors, they are already reported elsewhere or
// should remain silent.
err_inval!(AlreadyReported(info)) => ErrorHandled::Reported(info, span),
- err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => {
+ err_inval!(Layout(LayoutError::TooGeneric(_))) | err_inval!(TooGeneric) => {
ErrorHandled::TooGeneric(span)
}
err_inval!(Layout(LayoutError::ReferencesError(guar))) => {
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs
index 394719314612e..4c8f2735b9795 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs
@@ -201,7 +201,7 @@ fn should_emit_generic_error<'tcx>(abi: ExternAbi, layout_err: &'tcx LayoutError
use LayoutError::*;
match layout_err {
- Unknown(ty) => {
+ TooGeneric(ty) => {
match abi {
ExternAbi::CCmseNonSecureCall => {
// prevent double reporting of this error
@@ -211,7 +211,11 @@ fn should_emit_generic_error<'tcx>(abi: ExternAbi, layout_err: &'tcx LayoutError
_ => bug!("invalid ABI: {abi}"),
}
}
- SizeOverflow(..) | NormalizationFailure(..) | ReferencesError(..) | Cycle(..) => {
+ Unknown(..)
+ | SizeOverflow(..)
+ | NormalizationFailure(..)
+ | ReferencesError(..)
+ | Cycle(..) => {
false // not our job to report these
}
}
diff --git a/compiler/rustc_middle/messages.ftl b/compiler/rustc_middle/messages.ftl
index 5dd85978f007f..248321aec524f 100644
--- a/compiler/rustc_middle/messages.ftl
+++ b/compiler/rustc_middle/messages.ftl
@@ -100,6 +100,8 @@ middle_strict_coherence_needs_negative_coherence =
to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled
.label = due to this attribute
+middle_too_generic = `{$ty}` is too generic to determine the layout
+
middle_type_length_limit = reached the type-length limit while instantiating `{$shrunk}`
middle_unknown_layout =
@@ -107,4 +109,5 @@ middle_unknown_layout =
middle_values_too_big =
values of the type `{$ty}` are too big for the target architecture
+
middle_written_to_path = the full type name has been written to '{$path}'
diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs
index 6300d856393c6..b0187a1848cf1 100644
--- a/compiler/rustc_middle/src/error.rs
+++ b/compiler/rustc_middle/src/error.rs
@@ -129,6 +129,9 @@ pub enum LayoutError<'tcx> {
#[diag(middle_unknown_layout)]
Unknown { ty: Ty<'tcx> },
+ #[diag(middle_too_generic)]
+ TooGeneric { ty: Ty<'tcx> },
+
#[diag(middle_values_too_big)]
Overflow { ty: Ty<'tcx> },
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs
index 8d4d127607d34..46e18ea14ad2e 100644
--- a/compiler/rustc_middle/src/ty/layout.rs
+++ b/compiler/rustc_middle/src/ty/layout.rs
@@ -231,6 +231,7 @@ impl fmt::Display for ValidityRequirement {
pub enum LayoutError<'tcx> {
Unknown(Ty<'tcx>),
SizeOverflow(Ty<'tcx>),
+ TooGeneric(Ty<'tcx>),
NormalizationFailure(Ty<'tcx>, NormalizationError<'tcx>),
ReferencesError(ErrorGuaranteed),
Cycle(ErrorGuaranteed),
@@ -244,6 +245,7 @@ impl<'tcx> LayoutError<'tcx> {
match self {
Unknown(_) => middle_unknown_layout,
SizeOverflow(_) => middle_values_too_big,
+ TooGeneric(_) => middle_too_generic,
NormalizationFailure(_, _) => middle_cannot_be_normalized,
Cycle(_) => middle_cycle,
ReferencesError(_) => middle_layout_references_error,
@@ -257,6 +259,7 @@ impl<'tcx> LayoutError<'tcx> {
match self {
Unknown(ty) => E::Unknown { ty },
SizeOverflow(ty) => E::Overflow { ty },
+ TooGeneric(ty) => E::TooGeneric { ty },
NormalizationFailure(ty, e) => {
E::NormalizationFailure { ty, failure_ty: e.get_type_for_failure() }
}
@@ -272,6 +275,9 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
LayoutError::Unknown(ty) => write!(f, "the type `{ty}` has an unknown layout"),
+ LayoutError::TooGeneric(ty) => {
+ write!(f, "`{ty}` is too generic to determine the layout")
+ }
LayoutError::SizeOverflow(ty) => {
write!(f, "values of the type `{ty}` are too big for the target architecture")
}
@@ -350,10 +356,11 @@ impl<'tcx> SizeSkeleton<'tcx> {
return Err(tcx.arena.alloc(LayoutError::Unknown(ty)));
}
}
- Err(err @ LayoutError::Unknown(_)) => err,
+ Err(err @ LayoutError::TooGeneric(_)) => err,
// We can't extract SizeSkeleton info from other layout errors
Err(
e @ LayoutError::Cycle(_)
+ | e @ LayoutError::Unknown(_)
| e @ LayoutError::SizeOverflow(_)
| e @ LayoutError::NormalizationFailure(..)
| e @ LayoutError::ReferencesError(_),
diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs
index 6ce9969aefe90..b00585d292212 100644
--- a/compiler/rustc_transmute/src/layout/tree.rs
+++ b/compiler/rustc_transmute/src/layout/tree.rs
@@ -197,6 +197,7 @@ pub(crate) mod rustc {
match err {
LayoutError::Unknown(..)
| LayoutError::ReferencesError(..)
+ | LayoutError::TooGeneric(..)
| LayoutError::NormalizationFailure(..) => Self::UnknownLayout,
LayoutError::SizeOverflow(..) => Self::SizeOverflow,
LayoutError::Cycle(err) => Self::TypeError(*err),
diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs
index ab606478c5136..248877c81c5e1 100644
--- a/compiler/rustc_ty_utils/src/layout.rs
+++ b/compiler/rustc_ty_utils/src/layout.rs
@@ -104,7 +104,7 @@ fn map_error<'tcx>(
// This is sometimes not a compile error if there are trivially false where clauses.
// See `tests/ui/layout/trivial-bounds-sized.rs` for an example.
assert!(field.layout.is_unsized(), "invalid layout error {err:#?}");
- if !field.ty.is_sized(cx.tcx(), cx.typing_env) {
+ if cx.typing_env.param_env.caller_bounds().is_empty() {
cx.tcx().dcx().delayed_bug(format!(
"encountered unexpected unsized field in layout of {ty:?}: {field:#?}"
));
@@ -317,13 +317,13 @@ fn layout_of_uncached<'tcx>(
if count.has_aliases() {
count = tcx.normalize_erasing_regions(cx.typing_env, count);
if count.has_aliases() {
- return Err(error(cx, LayoutError::Unknown(ty)));
+ return Err(error(cx, LayoutError::TooGeneric(ty)));
}
}
let count = count
.try_to_target_usize(tcx)
- .ok_or_else(|| error(cx, LayoutError::Unknown(ty)))?;
+ .ok_or_else(|| error(cx, LayoutError::TooGeneric(ty)))?;
let element = cx.layout_of(element)?;
let size = element
.size
@@ -679,6 +679,9 @@ fn layout_of_uncached<'tcx>(
// Types with no meaningful known layout.
ty::Alias(..) => {
+ if ty.has_param() {
+ return Err(error(cx, LayoutError::TooGeneric(ty)));
+ }
// NOTE(eddyb) `layout_of` query should've normalized these away,
// if that was possible, so there's no reason to try again here.
return Err(error(cx, LayoutError::Unknown(ty)));
@@ -688,7 +691,11 @@ fn layout_of_uncached<'tcx>(
bug!("Layout::compute: unexpected type `{}`", ty)
}
- ty::Placeholder(..) | ty::Param(_) => {
+ ty::Param(_) => {
+ return Err(error(cx, LayoutError::TooGeneric(ty)));
+ }
+
+ ty::Placeholder(..) => {
return Err(error(cx, LayoutError::Unknown(ty)));
}
})
diff --git a/src/librustdoc/html/templates/type_layout.html b/src/librustdoc/html/templates/type_layout.html
index aee96fb8c417e..90049ea5998cd 100644
--- a/src/librustdoc/html/templates/type_layout.html
+++ b/src/librustdoc/html/templates/type_layout.html
@@ -44,6 +44,14 @@
{# #}
Note: Encountered an error during type layout; {#+ #}
the type was too big. {# #}
+ {# This kind of error probably can't happen with valid code, but we don't
+ want to panic and prevent the docs from building, so we just let the
+ user know that we couldn't compute the layout. #}
+ {% when Err(LayoutError::TooGeneric(_)) %}
+
{# #}
+ Note: Encountered an error during type layout; {#+ #}
+ the type was too generic. {# #}
+
{% when Err(LayoutError::ReferencesError(_)) %}
{# #}
Note: Encountered an error during type layout; {#+ #}
diff --git a/tests/crashes/135020.rs b/tests/crashes/135020.rs
deleted file mode 100644
index b44056eb3af30..0000000000000
--- a/tests/crashes/135020.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-//@ known-bug: #135020
-
-pub fn problem_thingy(items: &mut impl Iterator) {
- let mut peeker = items.peekable();
- match peeker.peek() {
- Some(_) => (),
- None => return (),
- }
-}
-
-pub fn main() {}
diff --git a/tests/ui/const-generics/transmute_no_gate.stderr b/tests/ui/const-generics/transmute_no_gate.stderr
index 9c271b34849c0..7902300b28948 100644
--- a/tests/ui/const-generics/transmute_no_gate.stderr
+++ b/tests/ui/const-generics/transmute_no_gate.stderr
@@ -4,8 +4,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[[u32; H]; W]` (this type does not have a fixed size)
- = note: target type: `[[u32; W]; H]` (this type does not have a fixed size)
+ = note: source type: `[[u32; H]; W]` (`[[u32; H]; W]` is too generic to determine the layout)
+ = note: target type: `[[u32; W]; H]` (`[[u32; W]; H]` is too generic to determine the layout)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute_no_gate.rs:20:5
@@ -13,8 +13,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[[u32; H]; W]` (this type does not have a fixed size)
- = note: target type: `[u32; W * H]` (this type does not have a fixed size)
+ = note: source type: `[[u32; H]; W]` (`[[u32; H]; W]` is too generic to determine the layout)
+ = note: target type: `[u32; W * H]` (`[u32; W * H]` is too generic to determine the layout)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute_no_gate.rs:27:5
@@ -22,8 +22,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[u32; H*W]` (this type does not have a fixed size)
- = note: target type: `[[u32; W]; H]` (this type does not have a fixed size)
+ = note: source type: `[u32; H*W]` (`[u32; H*W]` is too generic to determine the layout)
+ = note: target type: `[[u32; W]; H]` (`[[u32; W]; H]` is too generic to determine the layout)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute_no_gate.rs:36:5
@@ -31,8 +31,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[[[u32; D]; H]; W]` (this type does not have a fixed size)
- = note: target type: `[u32; D * W * H]` (this type does not have a fixed size)
+ = note: source type: `[[[u32; D]; H]; W]` (`[[[u32; D]; H]; W]` is too generic to determine the layout)
+ = note: target type: `[u32; D * W * H]` (`[u32; D * W * H]` is too generic to determine the layout)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute_no_gate.rs:45:5
@@ -40,8 +40,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[[[u32; D]; H]; W]` (this type does not have a fixed size)
- = note: target type: `[[u32; D * W]; H]` (this type does not have a fixed size)
+ = note: source type: `[[[u32; D]; H]; W]` (`[[[u32; D]; H]; W]` is too generic to determine the layout)
+ = note: target type: `[[u32; D * W]; H]` (`[[u32; D * W]; H]` is too generic to determine the layout)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute_no_gate.rs:52:5
@@ -49,8 +49,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[u16; L]` (this type does not have a fixed size)
- = note: target type: `[u8; L * 2]` (this type does not have a fixed size)
+ = note: source type: `[u16; L]` (`[u16; L]` is too generic to determine the layout)
+ = note: target type: `[u8; L * 2]` (`[u8; L * 2]` is too generic to determine the layout)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute_no_gate.rs:59:5
@@ -58,8 +58,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[u8; L * 2]` (this type does not have a fixed size)
- = note: target type: `[u16; L]` (this type does not have a fixed size)
+ = note: source type: `[u8; L * 2]` (`[u8; L * 2]` is too generic to determine the layout)
+ = note: target type: `[u16; L]` (`[u16; L]` is too generic to determine the layout)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute_no_gate.rs:66:5
@@ -67,8 +67,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[u8; L]` (this type does not have a fixed size)
- = note: target type: `[[u8; 1]; L]` (this type does not have a fixed size)
+ = note: source type: `[u8; L]` (`[u8; L]` is too generic to determine the layout)
+ = note: target type: `[[u8; 1]; L]` (`[[u8; 1]; L]` is too generic to determine the layout)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute_no_gate.rs:75:5
@@ -76,8 +76,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[[u32; 2 * H]; W + W]` (this type does not have a fixed size)
- = note: target type: `[[u32; W + W]; 2 * H]` (this type does not have a fixed size)
+ = note: source type: `[[u32; 2 * H]; W + W]` (`[[u32; 2 * H]; W + W]` is too generic to determine the layout)
+ = note: target type: `[[u32; W + W]; 2 * H]` (`[[u32; W + W]; 2 * H]` is too generic to determine the layout)
error: aborting due to 9 previous errors
diff --git a/tests/ui/issues/issue-21174.stderr b/tests/ui/issues/issue-21174.stderr
index a6b75c913524d..200e0dca56049 100644
--- a/tests/ui/issues/issue-21174.stderr
+++ b/tests/ui/issues/issue-21174.stderr
@@ -4,8 +4,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | let new: T::B = unsafe { std::mem::transmute(value) };
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `>::A` (this type does not have a fixed size)
- = note: target type: `>::B` (this type does not have a fixed size)
+ = note: source type: `>::A` (`>::A` is too generic to determine the layout)
+ = note: target type: `>::B` (`>::B` is too generic to determine the layout)
error: aborting due to 1 previous error
diff --git a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr
index 455bd2cbf8b6e..7e0a41a4367d6 100644
--- a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr
+++ b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr
@@ -23,7 +23,7 @@ LL | const C: S = unsafe { std::mem::transmute(()) };
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `()` (0 bits)
- = note: target type: `S` (size can vary because of [u8])
+ = note: target type: `S` (this type does not have a fixed size)
error: aborting due to 2 previous errors
diff --git a/tests/ui/layout/invalid-unsized-const-eval.rs b/tests/ui/layout/invalid-unsized-const-eval.rs
index 2dec0b0faacf2..1f664d30055d6 100644
--- a/tests/ui/layout/invalid-unsized-const-eval.rs
+++ b/tests/ui/layout/invalid-unsized-const-eval.rs
@@ -10,5 +10,6 @@ struct LazyLock {
}
static EMPTY_SET: LazyLock = todo!();
+//~^ ERROR could not evaluate static initializer
fn main() {}
diff --git a/tests/ui/layout/invalid-unsized-const-eval.stderr b/tests/ui/layout/invalid-unsized-const-eval.stderr
index bf65782b7a805..a434ca9b2c7cf 100644
--- a/tests/ui/layout/invalid-unsized-const-eval.stderr
+++ b/tests/ui/layout/invalid-unsized-const-eval.stderr
@@ -7,6 +7,13 @@ LL | data: (dyn Sync, ()),
= help: the trait `Sized` is not implemented for `(dyn Sync + 'static)`
= note: only the last element of a tuple may have a dynamically sized type
-error: aborting due to 1 previous error
+error[E0080]: could not evaluate static initializer
+ --> $DIR/invalid-unsized-const-eval.rs:12:1
+ |
+LL | static EMPTY_SET: LazyLock = todo!();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `(dyn Sync, ())` has an unknown layout
+
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0277`.
+Some errors have detailed explanations: E0080, E0277.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr
index 3f565d6ee5ba8..f54e97e2a5c76 100644
--- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr
+++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr
@@ -18,6 +18,20 @@ LL | struct MySlice(T);
| |
| this could be changed to `T: ?Sized`...
-error: aborting due to 1 previous error
+error[E0080]: could not evaluate static initializer
+ --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+ |
+ = note: the type `MySlice<[bool]>` has an unknown layout
+ |
+note: inside `align_of::`
+ --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+note: inside `CHECK`
+ --> $DIR/invalid-unsized-in-always-sized-tail.rs:15:28
+ |
+LL | static CHECK: () = assert!(align_of::() == 1);
+ | ^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0277`.
+Some errors have detailed explanations: E0080, E0277.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs
index 96c993035ef18..f84c10d8e5c03 100644
--- a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs
+++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs
@@ -6,5 +6,6 @@ struct ArenaSet::Target>(V, U);
//~^ ERROR the size for values of type `V` cannot be known at compilation time
const DATA: *const ArenaSet> = std::ptr::null_mut();
+//~^ ERROR evaluation of constant value failed
pub fn main() {}
diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
index f39cb29868af5..220951fab86f8 100644
--- a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
+++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
@@ -22,6 +22,13 @@ help: the `Box` type always has a statically known size and allocates its conten
LL | struct ArenaSet::Target>(Box, U);
| ++++ +
-error: aborting due to 1 previous error
+error[E0080]: evaluation of constant value failed
+ --> $DIR/issue-unsized-tail-restatic-ice-122488.rs:8:1
+ |
+LL | const DATA: *const ArenaSet> = std::ptr::null_mut();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `ArenaSet, [u8]>` has an unknown layout
+
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0277`.
+Some errors have detailed explanations: E0080, E0277.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs
new file mode 100644
index 0000000000000..91280e49dcd7e
--- /dev/null
+++ b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.rs
@@ -0,0 +1,11 @@
+#![feature(trivial_bounds)]
+
+fn return_str()
+where
+ str: Sized,
+{
+ [(); { let _a: Option = None; 0 }];
+ //~^ ERROR evaluation of constant value failed
+}
+
+fn main() {}
diff --git a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr
new file mode 100644
index 0000000000000..6c7c51db8df7f
--- /dev/null
+++ b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr
@@ -0,0 +1,9 @@
+error[E0080]: evaluation of constant value failed
+ --> $DIR/uncomputable-due-to-trivial-bounds-ice-135138.rs:7:16
+ |
+LL | [(); { let _a: Option = None; 0 }];
+ | ^^ the type `Option` has an unknown layout
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/layout/unexpected-unsized-field-issue-135020.rs b/tests/ui/layout/unexpected-unsized-field-issue-135020.rs
new file mode 100644
index 0000000000000..c81d037e510f2
--- /dev/null
+++ b/tests/ui/layout/unexpected-unsized-field-issue-135020.rs
@@ -0,0 +1,7 @@
+//@ check-pass
+
+fn problem_thingy(items: &mut impl Iterator) {
+ items.peekable();
+}
+
+fn main() {}
diff --git a/tests/ui/layout/unknown-when-no-type-parameter.rs b/tests/ui/layout/unknown-when-no-type-parameter.rs
new file mode 100644
index 0000000000000..c922090e9fc90
--- /dev/null
+++ b/tests/ui/layout/unknown-when-no-type-parameter.rs
@@ -0,0 +1,14 @@
+#![feature(trivial_bounds)]
+
+// The absence of `ERROR~` is because the span of the error is not reported
+// in the snippet, but in `core/src/mem/mod.rs`.
+
+trait Project {
+ type Assoc;
+}
+
+fn foo() where (): Project {
+ [(); size_of::<<() as Project>::Assoc>()];
+}
+
+fn main() {}
diff --git a/tests/ui/layout/unknown-when-no-type-parameter.stderr b/tests/ui/layout/unknown-when-no-type-parameter.stderr
new file mode 100644
index 0000000000000..d0456e2b3293b
--- /dev/null
+++ b/tests/ui/layout/unknown-when-no-type-parameter.stderr
@@ -0,0 +1,16 @@
+error[E0080]: evaluation of constant value failed
+ --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+ |
+ = note: the type `<() as Project>::Assoc` has an unknown layout
+ |
+note: inside `std::mem::size_of::<<() as Project>::Assoc>`
+ --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+note: inside `foo::{constant#0}`
+ --> $DIR/unknown-when-no-type-parameter.rs:11:10
+ |
+LL | [(); size_of::<<() as Project>::Assoc>()];
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/layout/unknown-when-ptr-metadata-is-1zst.rs b/tests/ui/layout/unknown-when-ptr-metadata-is-1zst.rs
new file mode 100644
index 0000000000000..973235fe65afc
--- /dev/null
+++ b/tests/ui/layout/unknown-when-ptr-metadata-is-1zst.rs
@@ -0,0 +1,12 @@
+#![feature(ptr_metadata)]
+#![feature(trivial_bounds)]
+
+fn return_str()
+where
+ str: std::ptr::Pointee,
+{
+ [(); { let _a: Option<&str> = None; 0 }];
+ //~^ ERROR evaluation of constant value failed
+}
+
+fn main() {}
diff --git a/tests/ui/layout/unknown-when-ptr-metadata-is-1zst.stderr b/tests/ui/layout/unknown-when-ptr-metadata-is-1zst.stderr
new file mode 100644
index 0000000000000..38a5bcc234e9e
--- /dev/null
+++ b/tests/ui/layout/unknown-when-ptr-metadata-is-1zst.stderr
@@ -0,0 +1,9 @@
+error[E0080]: evaluation of constant value failed
+ --> $DIR/unknown-when-ptr-metadata-is-1zst.rs:8:16
+ |
+LL | [(); { let _a: Option<&str> = None; 0 }];
+ | ^^ the type `str` has an unknown layout
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/repr/conflicting-repr-hints.rs b/tests/ui/repr/conflicting-repr-hints.rs
index ed82b6a742c8d..2e8305a245cd9 100644
--- a/tests/ui/repr/conflicting-repr-hints.rs
+++ b/tests/ui/repr/conflicting-repr-hints.rs
@@ -74,7 +74,7 @@ pub union U { //~ ERROR type has conflicting packed and align representation hin
u: u16
}
-static B: U = U { u: 0 };
+static B: U = U { u: 0 }; //~ ERROR could not evaluate static initializer
static A: S = S(0);
fn main() {}
diff --git a/tests/ui/repr/conflicting-repr-hints.stderr b/tests/ui/repr/conflicting-repr-hints.stderr
index fbfa69e7fb145..1ccdbf57caa64 100644
--- a/tests/ui/repr/conflicting-repr-hints.stderr
+++ b/tests/ui/repr/conflicting-repr-hints.stderr
@@ -77,10 +77,16 @@ error[E0587]: type has conflicting packed and align representation hints
LL | pub union U {
| ^^^^^^^^^^^
-error: aborting due to 12 previous errors
+error[E0080]: could not evaluate static initializer
+ --> $DIR/conflicting-repr-hints.rs:77:1
+ |
+LL | static B: U = U { u: 0 };
+ | ^^^^^^^^^^^ the type `U` has an unknown layout
+
+error: aborting due to 13 previous errors
-Some errors have detailed explanations: E0566, E0587, E0634.
-For more information about an error, try `rustc --explain E0566`.
+Some errors have detailed explanations: E0080, E0566, E0587, E0634.
+For more information about an error, try `rustc --explain E0080`.
Future incompatibility report: Future breakage diagnostic:
error[E0566]: conflicting representation hints
--> $DIR/conflicting-repr-hints.rs:13:8
diff --git a/tests/ui/simd/monomorphize-heterogeneous.rs b/tests/ui/simd/monomorphize-heterogeneous.rs
index 326e52acc34d1..279c325068761 100644
--- a/tests/ui/simd/monomorphize-heterogeneous.rs
+++ b/tests/ui/simd/monomorphize-heterogeneous.rs
@@ -9,5 +9,6 @@ struct I64x4F64x0([i64; 4], [f64; 0]);
//~^ ERROR SIMD vector cannot have multiple fields
static X: I64F64 = I64F64(1, 2.0);
+//~^ ERROR could not evaluate static initializer
fn main() {}
diff --git a/tests/ui/simd/monomorphize-heterogeneous.stderr b/tests/ui/simd/monomorphize-heterogeneous.stderr
index 610a1a49038aa..bcff47b0274dc 100644
--- a/tests/ui/simd/monomorphize-heterogeneous.stderr
+++ b/tests/ui/simd/monomorphize-heterogeneous.stderr
@@ -10,7 +10,13 @@ error[E0075]: SIMD vector cannot have multiple fields
LL | struct I64x4F64x0([i64; 4], [f64; 0]);
| ^^^^^^^^^^^^^^^^^ -------- excess field
-error: aborting due to 2 previous errors
+error[E0080]: could not evaluate static initializer
+ --> $DIR/monomorphize-heterogeneous.rs:11:1
+ |
+LL | static X: I64F64 = I64F64(1, 2.0);
+ | ^^^^^^^^^^^^^^^^ the type `I64F64` has an unknown layout
+
+error: aborting due to 3 previous errors
-Some errors have detailed explanations: E0075, E0076.
+Some errors have detailed explanations: E0075, E0076, E0080.
For more information about an error, try `rustc --explain E0075`.
diff --git a/tests/ui/structs/ice-struct-tail-normalization-113272.rs b/tests/ui/structs/ice-struct-tail-normalization-113272.rs
index 85d3d1b4886f7..ce2871fabb8c5 100644
--- a/tests/ui/structs/ice-struct-tail-normalization-113272.rs
+++ b/tests/ui/structs/ice-struct-tail-normalization-113272.rs
@@ -13,5 +13,6 @@ struct Other {
fn main() {
unsafe {
std::mem::transmute::