Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --:
with debug assertions: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
without: --<details<summary<strongBacktrace</strong</summary<p</p</details

Discussion:
let mut error_happened = false; <ins> if variant.fields.len() != remaining_fields.len() { // Some field is defined more than once. Make sure we don't try to // instantiate this struct in static/const context. let guar = self.dcx().span_delayed_bug(expr.span, "struct fields have non-unique names"); self.set_tainted_by_errors(guar); error_happened = true; } </ins> // Type-check each field. for (idx, field) in hir_fields.iter().enumerate() { let ident = tcx.adjust_ident(field.ident, variant.def_id);

<del> //@ known-bug: rust-lang/rust #124464 enum TestOption<T> { TestSome(T), TestSome(T), } pub struct Request { bar: TestOption<u64>, bar: u8, } fn default_instance() -> &'static Request { static instance: Request = Request { bar: 17 }; &instance } pub fn main() {} </del>

<del> //@ known-bug: rust-lang/rust#124552 struct B; struct Foo { b: u32, b: B, } static BAR: Foo = Foo { b: B }; fn main() {} </del>

<ins> // Don't const eval fields with ambiguous layout. // See issues #125842 and #124464. enum TestOption<T> { TestSome(T), TestSome(T), //~^ ERROR the name `TestSome` is defined multiple times } pub struct Request { bar: TestOption<u64>, bar: u8, //~^ ERROR field `bar` is already declared } fn default_instance() -> &'static Request { static instance: Request = Request { bar: 17 }; &instance } pub fn main() {} </ins>

<ins> error[E0428]: the name `TestSome` is defined multiple times --> $DIR/duplicated-fields-issue-124464.rs:6:5 | LL |     TestSome(T), |     ----------- previous definition of the type `TestSome` here LL |     TestSome(T), |     ^^^^^^^^^^^ `TestSome` redefined here | = note: `TestSome` must be defined only once in the type namespace of this enum error[E0124]: field `bar` is already declared --> $DIR/duplicated-fields-issue-124464.rs:12:5 | LL |     bar: TestOption<u64>, |     -------------------- `bar` first declared here LL |     bar: u8, |     ^^^^^^^ field already declared error: aborting due to 2 previous errors Some errors have detailed explanations: E0124, E0428. For more information about an error, try `rustc --explain E0124`. </ins>

<ins> // Do not try to evaluate static initalizers that reference // ill-defined types. This used to be an ICE. // See issues #125842 and #124464. struct Struct { field: Option<u8>, field: u8, //~^ ERROR field `field` is already declared } static STATIC_A: Struct = Struct { field: 1 }; static STATIC_B: Struct = { let field = 1; Struct { field, } }; fn main() {} </ins>

<ins> error[E0124]: field `field` is already declared --> $DIR/duplicated-fields-issue-125842.rs:6:5 | LL |     field: Option<u8>, |     ----------------- `field` first declared here LL |     field: u8, |     ^^^^^^^^^ field already declared error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0124`. </ins>