Skip to content

Commit 5784a03

Browse files
authored
Rollup merge of rust-lang#103870 - TaKO8Ki:fix-103790, r=fee1-dead
Fix `inferred_kind` ICE Fixes rust-lang#103790
2 parents 0f72a6d + b96ad1c commit 5784a03

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
500500
}
501501
GenericParamDefKind::Const { has_default } => {
502502
let ty = tcx.at(self.span).type_of(param.def_id);
503+
if ty.references_error() {
504+
return tcx.const_error(ty).into();
505+
}
503506
if !infer_args && has_default {
504507
tcx.bound_const_param_default(param.def_id)
505508
.subst(tcx, substs.unwrap())

src/test/ui/consts/issue-103790.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
struct S<const S: (), const S: S = { S }>;
5+
//~^ ERROR the name `S` is already used for a generic parameter in this item's generic parameters
6+
//~| ERROR missing generics for struct `S`
7+
//~| ERROR cycle detected when computing type of `S::S`
8+
//~| ERROR cycle detected when computing type of `S`
9+
10+
fn main() {}
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
error[E0403]: the name `S` is already used for a generic parameter in this item's generic parameters
2+
--> $DIR/issue-103790.rs:4:29
3+
|
4+
LL | struct S<const S: (), const S: S = { S }>;
5+
| - ^ already used
6+
| |
7+
| first use of `S`
8+
9+
error[E0107]: missing generics for struct `S`
10+
--> $DIR/issue-103790.rs:4:32
11+
|
12+
LL | struct S<const S: (), const S: S = { S }>;
13+
| ^ expected at least 1 generic argument
14+
|
15+
note: struct defined here, with at least 1 generic parameter: `S`
16+
--> $DIR/issue-103790.rs:4:8
17+
|
18+
LL | struct S<const S: (), const S: S = { S }>;
19+
| ^ -----------
20+
help: add missing generic argument
21+
|
22+
LL | struct S<const S: (), const S: S<S> = { S }>;
23+
| ~~~~
24+
25+
error[E0391]: cycle detected when computing type of `S::S`
26+
--> $DIR/issue-103790.rs:4:32
27+
|
28+
LL | struct S<const S: (), const S: S = { S }>;
29+
| ^
30+
|
31+
= note: ...which immediately requires computing type of `S::S` again
32+
note: cycle used when computing type of `S`
33+
--> $DIR/issue-103790.rs:4:1
34+
|
35+
LL | struct S<const S: (), const S: S = { S }>;
36+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
37+
38+
error[E0391]: cycle detected when computing type of `S`
39+
--> $DIR/issue-103790.rs:4:1
40+
|
41+
LL | struct S<const S: (), const S: S = { S }>;
42+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
|
44+
note: ...which requires computing type of `S::S`...
45+
--> $DIR/issue-103790.rs:4:32
46+
|
47+
LL | struct S<const S: (), const S: S = { S }>;
48+
| ^
49+
= note: ...which again requires computing type of `S`, completing the cycle
50+
note: cycle used when collecting item types in top-level module
51+
--> $DIR/issue-103790.rs:1:1
52+
|
53+
LL | / #![feature(generic_const_exprs)]
54+
LL | | #![allow(incomplete_features)]
55+
LL | |
56+
LL | | struct S<const S: (), const S: S = { S }>;
57+
... |
58+
LL | |
59+
LL | | fn main() {}
60+
| |____________^
61+
62+
error: aborting due to 4 previous errors
63+
64+
Some errors have detailed explanations: E0107, E0391, E0403.
65+
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)