Skip to content

Fix ICE in pointer layout for DSTs with bogus Sized impls#155260

Open
GokhanKabar wants to merge 1 commit intorust-lang:mainfrom
GokhanKabar:fix-ice-bogus-sized-impl-layout
Open

Fix ICE in pointer layout for DSTs with bogus Sized impls#155260
GokhanKabar wants to merge 1 commit intorust-lang:mainfrom
GokhanKabar:fix-ice-bogus-sized-impl-layout

Conversation

@GokhanKabar
Copy link
Copy Markdown
Contributor

@GokhanKabar GokhanKabar commented Apr 13, 2026

Fixes #155252.

Summary

A bogus impl<T: ?Sized> Sized for T {} (rejected as E0322) was processed by the new trait solver (-Znext-solver=globally), making DSTs like [T] appear sized. This caused *const [T] to receive a thin-pointer (Scalar) layout instead of a fat-pointer (ScalarPair) layout in rustc_ty_utils/src/layout.rs.

When const evaluation then performed an array-to-slice unsizing coercion (unsize_into_ptr) and tried to write the resulting ScalarPair value to a Scalar-layout place, it triggered an ICE:

error: internal compiler error: invalid immediate for given destination place:
value ScalarPair(alloc<imm>, 0x2) does not match ABI Scalar(...)

Fix

In compiler/rustc_ty_utils/src/layout.rs, after is_sized returns true for the pointee, we cross-check using struct_tail_for_codegen — a purely structural traversal that is unaffected by bogus trait impls. If the tail is a known DST kind (Slice / Str / Dynamic), we skip the thin-pointer early return and fall through to compute the correct fat-pointer (ScalarPair) layout.

This approach is safe because struct_tail_for_codegen does not invoke the trait solver, so it cannot be misled by the bogus Sized impl.

Test

Added tests/ui/traits/next-solver/dont-ice-on-bogus-sized-impl-in-const-block.rs which previously ICE'd and now produces the expected E0322 + E0210 errors.

A bogus `impl<T: ?Sized> Sized for T {}` (rejected as E0322) was
processed by the new trait solver (`-Znext-solver=globally`), making
DSTs like `[T]` appear sized. This caused `*const [T]` to receive a
thin-pointer (Scalar) layout instead of a fat-pointer (ScalarPair)
layout. When const evaluation then performed an array-to-slice unsizing
coercion and tried to write a ScalarPair value to a Scalar-layout place,
it triggered an ICE:

  "invalid immediate for given destination place: value ScalarPair(...)
   does not match ABI Scalar(...)"

The fix adds a structural cross-check in the pointer layout computation:
after `is_sized` returns true, we verify via `struct_tail_for_codegen`
(which is purely structural and unaffected by bogus trait impls) that
the pointee tail is not a known DST kind (Slice/Str/Dynamic). If it is,
we skip the thin-pointer early return and fall through to compute the
correct fat-pointer layout.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Apr 13, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 13, 2026

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 13 candidates

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
PR_CI_JOB set; skipping tidy
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
---
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.stderr`
diff of stderr:

17    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
18    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
19 
+ error: reached the recursion limit finding the struct tail for `[u8; 256]`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: reached the recursion limit finding the struct tail for `[u8; 256]`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
20 note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>`
21   --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:38:18
22    |

26    = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt'
27    = note: consider using `--verbose` to print the full type name to the console
28 
+ error: reached the recursion limit finding the struct tail for `[u8; 256]`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ note: the above error was encountered while instantiating `fn <VirtualWrapper<..., 1> as MyTrait>::virtualize`
+    |
+    = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt'
+    = note: consider using `--verbose` to print the full type name to the console
+ 
29 error: reached the recursion limit finding the struct tail for `SomeData<256>`
30    |
31    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`

45    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
46    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
47 
+ error: reached the recursion limit finding the struct tail for `SomeData<256>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: reached the recursion limit finding the struct tail for `SomeData<256>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
48 note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>`
49   --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:38:18
50    |

54    = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt'
55    = note: consider using `--verbose` to print the full type name to the console
56 
+ error: reached the recursion limit finding the struct tail for `SomeData<256>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ note: the above error was encountered while instantiating `fn <VirtualWrapper<..., 1> as MyTrait>::virtualize`
+    |
+    = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt'
+    = note: consider using `--verbose` to print the full type name to the console
+ 
57 error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
58    |
59    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`

73    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
74    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
75 
+ error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
76 note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>`
77   --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:38:18
78    |

92    = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt'
93    = note: consider using `--verbose` to print the full type name to the console
94 
- error: aborting due to 13 previous errors
+ error: aborting due to 21 previous errors
96 
97 

Note: some mismatched output was normalized before being compared
-    = note: the full name for the type has been written to '/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type-9361727215574671438.txt'
-    = note: the full name for the type has been written to '/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type-11691801779463543373.txt'
+ error: reached the recursion limit finding the struct tail for `[u8; 256]`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: reached the recursion limit finding the struct tail for `[u8; 256]`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: reached the recursion limit finding the struct tail for `[u8; 256]`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ note: the above error was encountered while instantiating `fn <VirtualWrapper<..., 1> as MyTrait>::virtualize`
+    |
+    = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt'
+    = note: consider using `--verbose` to print the full type name to the console
+ 
+ error: reached the recursion limit finding the struct tail for `SomeData<256>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: reached the recursion limit finding the struct tail for `SomeData<256>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: reached the recursion limit finding the struct tail for `SomeData<256>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ note: the above error was encountered while instantiating `fn <VirtualWrapper<..., 1> as MyTrait>::virtualize`
+    |
+    = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt'
+    = note: consider using `--verbose` to print the full type name to the console
+ 
+ error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
+    |
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+ 
+ error: aborting due to 21 previous errors


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args infinite/infinite-instantiation-struct-tail-ice-114484.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--diagnostic-width=100" "-Zwrite-long-types-to-disk=yes"
stdout: none
--- stderr -------------------------------
error: reached the recursion limit finding the struct tail for `[u8; 256]`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`

error: reached the recursion limit finding the struct tail for `[u8; 256]`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `[u8; 256]`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `[u8; 256]`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `[u8; 256]`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `[u8; 256]`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>`
  --> /checkout/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs:38:18
   |
LL |         unsafe { virtualize_my_trait(L, self) }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the full name for the type has been written to '/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type-1676262549976876142.txt'
   = note: consider using `--verbose` to print the full type name to the console

error: reached the recursion limit finding the struct tail for `[u8; 256]`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

note: the above error was encountered while instantiating `fn <VirtualWrapper<..., 1> as MyTrait>::virtualize`
   |
   = note: the full name for the type has been written to '/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type-9361727215574671438.txt'
   = note: consider using `--verbose` to print the full type name to the console

error: reached the recursion limit finding the struct tail for `SomeData<256>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`

error: reached the recursion limit finding the struct tail for `SomeData<256>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `SomeData<256>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `SomeData<256>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `SomeData<256>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `SomeData<256>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>`
  --> /checkout/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs:38:18
   |
LL |         unsafe { virtualize_my_trait(L, self) }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the full name for the type has been written to '/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type-10065815589733542395.txt'
   = note: consider using `--verbose` to print the full type name to the console

error: reached the recursion limit finding the struct tail for `SomeData<256>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

note: the above error was encountered while instantiating `fn <VirtualWrapper<..., 1> as MyTrait>::virtualize`
   |
   = note: the full name for the type has been written to '/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type-11691801779463543373.txt'
   = note: consider using `--verbose` to print the full type name to the console

error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`

error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: reached the recursion limit finding the struct tail for `VirtualWrapper<SomeData<256>, 0>`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

note: the above error was encountered while instantiating `fn virtualize_my_trait::<VirtualWrapper<..., 1>>`
  --> /checkout/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs:38:18
   |
LL |         unsafe { virtualize_my_trait(L, self) }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the full name for the type has been written to '/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type-10906200563314185289.txt'
   = note: consider using `--verbose` to print the full type name to the console

error: reached the recursion limit while instantiating `<VirtualWrapper<..., 1> as MyTrait>::virtualize`
   |
note: `<VirtualWrapper<T, L> as MyTrait>::virtualize` defined here
  --> /checkout/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs:37:5
   |
LL |     fn virtualize(&self) -> &dyn MyTrait {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: the full name for the type has been written to '/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/infinite/infinite-instantiation-struct-tail-ice-114484/infinite-instantiation-struct-tail-ice-114484.long-type-2069826520915733497.txt'
   = note: consider using `--verbose` to print the full type name to the console

error: aborting due to 21 previous errors
------------------------------------------

---
+    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
+ 
1 error[E0391]: cycle detected when computing layout of `Foo`
2    |
3    = note: ...which requires computing layout of `<&'static Foo as core::ops::deref::Deref>::Target`...

9    | ^^^^^^^^^^^^^^^^^^^
10    = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
11 
- error: aborting due to 1 previous error
---
To only update this specific test, also pass `--test-args sized/stack-overflow-trait-infer-98842.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/sized/stack-overflow-trait-infer-98842.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/sized/stack-overflow-trait-infer-98842" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error: reached the recursion limit finding the struct tail for `<&'static Foo as Deref>::Target`
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`

error[E0391]: cycle detected when computing layout of `Foo`
   |
   = note: ...which requires computing layout of `<&'static Foo as core::ops::deref::Deref>::Target`...
   = note: ...which again requires computing layout of `Foo`, completing the cycle
note: cycle used when const-evaluating + checking `_`
  --> /checkout/tests/ui/sized/stack-overflow-trait-infer-98842.rs:13:1
   |
LL | const _: *const Foo = 0 as _;
   | ^^^^^^^^^^^^^^^^^^^
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

@jieyouxu jieyouxu assigned jieyouxu and unassigned nnethercote Apr 14, 2026
@jieyouxu jieyouxu added the S-no-work-capacity-tracking Status: Exempted from triagebot work capacity tracking. label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-no-work-capacity-tracking Status: Exempted from triagebot work capacity tracking. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: Got a scalar pair where a scalar was expected

5 participants