Skip to content

Add regression test for #138710 (interpret queries ICE)#154789

Closed
Herrtian wants to merge 1 commit intorust-lang:mainfrom
Herrtian:add-test-138710-interpret-queries-ice
Closed

Add regression test for #138710 (interpret queries ICE)#154789
Herrtian wants to merge 1 commit intorust-lang:mainfrom
Herrtian:add-test-138710-interpret-queries-ice

Conversation

@Herrtian
Copy link
Copy Markdown

@Herrtian Herrtian commented Apr 3, 2026

Summary

Adds a regression test for #138710.

Using min_generic_const_args with associated types and consts in an async function returning a dyn trait used to ICE in rustc_middle::mir::interpret::queries. The compiler now correctly reports errors without crashing.

Test

tests/ui/consts/ice-interpret-queries-138710.rs

Closes #138710

This code used to ICE in rustc_middle::mir::interpret::queries when
using min_generic_const_args with associated types/consts in an async
function returning a dyn trait. The compiler now reports errors without
crashing.
@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. labels Apr 3, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

r? @petrochenkov

rustbot has assigned @petrochenkov.
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 10 candidates

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@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]
---
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/consts/ice-interpret-queries-138710.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/consts/ice-interpret-queries-138710/ice-interpret-queries-138710.stderr`
diff of stderr:

- warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/ice-interpret-queries-138710.rs:7:12
-   |
---
43 LL | trait A {
-   |       - this trait is not dyn compatible...
+    |       - this trait is not dyn compatible...
45 LL |     const N: usize;
-   |           ^ ...because it contains associated const `N` that's not defined as `type const`
-   = help: consider moving `N` to another trait
+    |           ^ ...because it contains associated const `N` that's not defined as `type const`
+    = help: consider moving `N` to another trait
48 
- error: aborting due to 3 previous errors; 1 warning emitted
+ error: aborting due to 3 previous errors
50 
51 Some errors have detailed explanations: E0038, E0277.
---
+    |      ^^^^^^^^^^ `A` is not dyn compatible
+    |
+   --> $DIR/ice-interpret-queries-138710.rs:16:11
+    |
+    |       - this trait is not dyn compatible...
+    |           ^ ...because it contains associated const `N` that's not defined as `type const`
+    = help: consider moving `N` to another trait
+ error: aborting due to 3 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 consts/ice-interpret-queries-138710.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/consts/ice-interpret-queries-138710.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/consts/ice-interpret-queries-138710" "-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: use of `const` in the type system not defined as `type const`
##[error]  --> /checkout/tests/ui/consts/ice-interpret-queries-138710.rs:21:16
   |
LL |     *(&mut [0; <<Vec<u32> as B>::n as A>::N])
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: add `type` before `const` for `A::N`
   |
LL |     type const N: usize;
   |     ++++

error[E0277]: the trait bound `Vec<u32>: B` is not satisfied
##[error]  --> /checkout/tests/ui/consts/ice-interpret-queries-138710.rs:21:18
   |
LL |     *(&mut [0; <<Vec<u32> as B>::n as A>::N])
   |                  ^^^^^^^^ the trait `B` is not implemented for `Vec<u32>`
   |
help: this trait has no implementations, consider adding one
  --> /checkout/tests/ui/consts/ice-interpret-queries-138710.rs:12:1
   |
LL | trait B {
---
   |
LL | trait A {
   |       - this trait is not dyn compatible...
LL |     const N: usize;
   |           ^ ...because it contains associated const `N` that's not defined as `type const`
   = help: consider moving `N` to another trait

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0038, E0277.
For more information about an error, try `rustc --explain E0038`.

@lqd
Copy link
Copy Markdown
Member

lqd commented Apr 4, 2026

#138710 is also likely a duplicate, se we probably shouldn’t add a test for it. There are more details in this other already reviewed PR adding the same test #147218

@Herrtian
Copy link
Copy Markdown
Author

Herrtian commented Apr 4, 2026

You're right, this is a duplicate. Closing in favor of the existing test PR. Thank you for pointing this out.

@Herrtian Herrtian closed this Apr 4, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: rustc panicked at compiler\rustc_middle\src\mir\interpret\queries.rs:104:13

5 participants