Skip to content

Commit 7debd12

Browse files
committed
Add regression test for ICE #138710 (min_generic_const_args)
1 parent 1e1a394 commit 7debd12

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// edition:2024
2+
// compile-fail
3+
// Regression test for issue #138710
4+
// ICE: rustc panicked at compiler\rustc_middle\src\mir\interpret\queries.rs:104:13
5+
6+
#![feature(min_generic_const_args)]
7+
8+
trait B {
9+
type N: A;
10+
}
11+
12+
trait A {
13+
const N: usize;
14+
}
15+
16+
async fn fun() -> Box<dyn A> {
17+
*(&mut [0; <<Vec<u32> as B>::N as A>::N])
18+
}
19+
20+
fn main() {}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
error[E0670]: `async fn` is not permitted in Rust 2015
2+
--> $DIR/issue-138710.rs:16:1
3+
|
4+
LL | async fn fun() -> Box<dyn A> {
5+
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
6+
|
7+
= help: pass `--edition 2024` to `rustc`
8+
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
9+
10+
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
11+
--> $DIR/issue-138710.rs:6:12
12+
|
13+
LL | #![feature(min_generic_const_args)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
17+
= note: `#[warn(incomplete_features)]` on by default
18+
19+
error[E0277]: the trait bound `Vec<u32>: B` is not satisfied
20+
--> $DIR/issue-138710.rs:17:18
21+
|
22+
LL | *(&mut [0; <<Vec<u32> as B>::N as A>::N])
23+
| ^^^^^^^^ the trait `B` is not implemented for `Vec<u32>`
24+
|
25+
help: this trait has no implementations, consider adding one
26+
--> $DIR/issue-138710.rs:8:1
27+
|
28+
LL | trait B {
29+
| ^^^^^^^
30+
31+
error[E0308]: mismatched types
32+
--> $DIR/issue-138710.rs:17:5
33+
|
34+
LL | *(&mut [0; <<Vec<u32> as B>::N as A>::N])
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn A>`, found `[{integer}; _]`
36+
|
37+
= note: expected struct `Box<(dyn A + 'static)>`
38+
found array `[{integer}; _]`
39+
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
40+
help: store this in the heap by calling `Box::new`
41+
|
42+
LL | Box::new(*(&mut [0; <<Vec<u32> as B>::N as A>::N]))
43+
| +++++++++ +
44+
45+
error[E0038]: the trait `A` is not dyn compatible
46+
--> $DIR/issue-138710.rs:16:1
47+
|
48+
LL | async fn fun() -> Box<dyn A> {
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `A` is not dyn compatible
50+
|
51+
note: for a trait to be dyn compatible it needs to allow building a vtable
52+
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
53+
--> $DIR/issue-138710.rs:13:11
54+
|
55+
LL | trait A {
56+
| - this trait is not dyn compatible...
57+
LL | const N: usize;
58+
| ^ ...because it contains this associated `const`
59+
= help: consider moving `N` to another trait
60+
61+
error: aborting due to 4 previous errors; 1 warning emitted
62+
63+
Some errors have detailed explanations: E0038, E0277, E0308, E0670.
64+
For more information about an error, try `rustc --explain E0038`.

0 commit comments

Comments
 (0)