Skip to content

Commit 94a8092

Browse files
committed
wip on constargkind::path for all paths
lots of ICEs and other bad changes
1 parent e3366ad commit 94a8092

20 files changed

+53
-385
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,14 +2334,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23342334
} else {
23352335
&anon.value
23362336
};
2337-
let maybe_res =
2338-
self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
2339-
debug!("res={:?}", maybe_res);
2340-
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
2341-
if let Some(res) = maybe_res
2342-
&& let Res::Def(DefKind::ConstParam, _) = res
2343-
&& let ExprKind::Path(qself, path) = &expr.kind
2344-
{
2337+
if let ExprKind::Path(qself, path) = &expr.kind {
23452338
let qpath = self.lower_qpath(
23462339
expr.id,
23472340
qself,
Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/bad-generic-in-copy-impl.rs:3:13
1+
error: the constant `1` is not of type `usize`
2+
--> $DIR/bad-generic-in-copy-impl.rs:3:8
33
|
44
LL | x: [u8; SIZE],
5-
| ^^^^ expected `usize`, found `u32`
5+
| ^^^^^^^^^^ expected `usize`, found `u32`
66

7-
error[E0308]: mismatched types
8-
--> $DIR/bad-generic-in-copy-impl.rs:3:13
7+
error[E0204]: the trait `Copy` cannot be implemented for this type
8+
--> $DIR/bad-generic-in-copy-impl.rs:1:10
99
|
10+
LL | #[derive(Copy, Clone)]
11+
| ^^^^
12+
LL | pub struct Foo {
1013
LL | x: [u8; SIZE],
11-
| ^^^^ expected `usize`, found `u32`
14+
| ------------- this field does not implement `Copy`
1215
|
13-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
16+
note: the `Copy` impl for `[u8; 1]` requires that `the constant `1` has type `usize``
17+
--> $DIR/bad-generic-in-copy-impl.rs:3:8
18+
|
19+
LL | x: [u8; SIZE],
20+
| ^^^^^^^^^^
21+
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+
error: the constant `1` is not of type `usize`
24+
--> $DIR/bad-generic-in-copy-impl.rs:3:5
25+
|
26+
LL | #[derive(Copy, Clone)]
27+
| ----- in this derive macro expansion
28+
LL | pub struct Foo {
29+
LL | x: [u8; SIZE],
30+
| ^^^^^^^^^^^^^ expected `usize`, found `u32`
31+
|
32+
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
1433

15-
error: aborting due to 2 previous errors
34+
error: aborting due to 3 previous errors
1635

17-
For more information about this error, try `rustc --explain E0308`.
36+
For more information about this error, try `rustc --explain E0204`.

tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,6 @@ LL | pub struct SelfDependent<const N: [u8; N]>;
1414
|
1515
= note: const parameters may not be used in the type of const parameters
1616

17-
error: `[u8; N]` is forbidden as the type of a const generic parameter
18-
--> $DIR/const-param-type-depends-on-const-param.rs:11:47
19-
|
20-
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
21-
| ^^^^^^^
22-
|
23-
= note: the only supported types are integers, `bool`, and `char`
24-
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
25-
|
26-
LL + #![feature(adt_const_params)]
27-
|
28-
29-
error: `[u8; N]` is forbidden as the type of a const generic parameter
30-
--> $DIR/const-param-type-depends-on-const-param.rs:15:35
31-
|
32-
LL | pub struct SelfDependent<const N: [u8; N]>;
33-
| ^^^^^^^
34-
|
35-
= note: the only supported types are integers, `bool`, and `char`
36-
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
37-
|
38-
LL + #![feature(adt_const_params)]
39-
|
40-
41-
error: aborting due to 4 previous errors
17+
error: aborting due to 2 previous errors
4218

4319
For more information about this error, try `rustc --explain E0770`.

tests/ui/const-generics/fn-const-param-infer.adt_const_params.stderr

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ error[E0741]: using function pointers as const generic parameters is forbidden
44
LL | struct Checked<const F: fn(usize) -> bool>;
55
| ^^^^^^^^^^^^^^^^^
66

7-
error[E0308]: mismatched types
8-
--> $DIR/fn-const-param-infer.rs:33:25
9-
|
10-
LL | let _ = Checked::<{ generic_arg::<u32> }>;
11-
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
12-
|
13-
= note: expected fn pointer `fn(usize) -> _`
14-
found fn item `fn(u32) -> _ {generic_arg::<u32>}`
15-
16-
error: aborting due to 2 previous errors
7+
error: aborting due to 1 previous error
178

18-
Some errors have detailed explanations: E0308, E0741.
19-
For more information about an error, try `rustc --explain E0308`.
9+
For more information about this error, try `rustc --explain E0741`.

tests/ui/const-generics/fn-const-param-infer.full.stderr

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ error[E0741]: using function pointers as const generic parameters is forbidden
44
LL | struct Checked<const F: fn(usize) -> bool>;
55
| ^^^^^^^^^^^^^^^^^
66

7-
error[E0308]: mismatched types
8-
--> $DIR/fn-const-param-infer.rs:33:25
9-
|
10-
LL | let _ = Checked::<{ generic_arg::<u32> }>;
11-
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
12-
|
13-
= note: expected fn pointer `fn(usize) -> _`
14-
found fn item `fn(u32) -> _ {generic_arg::<u32>}`
15-
16-
error: aborting due to 2 previous errors
7+
error: aborting due to 1 previous error
178

18-
Some errors have detailed explanations: E0308, E0741.
19-
For more information about an error, try `rustc --explain E0308`.
9+
For more information about this error, try `rustc --explain E0741`.

tests/ui/const-generics/fn-const-param-infer.min.stderr

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,5 @@ LL | struct Checked<const F: fn(usize) -> bool>;
66
|
77
= note: the only supported types are integers, `bool`, and `char`
88

9-
error[E0308]: mismatched types
10-
--> $DIR/fn-const-param-infer.rs:33:25
11-
|
12-
LL | let _ = Checked::<{ generic_arg::<u32> }>;
13-
| ^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
14-
|
15-
= note: expected fn pointer `fn(usize) -> _`
16-
found fn item `fn(u32) -> _ {generic_arg::<u32>}`
17-
18-
error: aborting due to 2 previous errors
9+
error: aborting due to 1 previous error
1910

20-
For more information about this error, try `rustc --explain E0308`.

tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,6 @@ LL | pub struct A<const z: [usize; x]> {}
66
| |
77
| similarly named const parameter `z` defined here
88

9-
error: `[usize; x]` is forbidden as the type of a const generic parameter
10-
--> $DIR/error_in_ty.rs:6:23
11-
|
12-
LL | pub struct A<const z: [usize; x]> {}
13-
| ^^^^^^^^^^
14-
|
15-
= note: the only supported types are integers, `bool`, and `char`
16-
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
17-
|
18-
LL + #![feature(adt_const_params)]
19-
|
20-
21-
error[E0308]: mismatched types
22-
--> $DIR/error_in_ty.rs:10:8
23-
|
24-
LL | impl A<2> {
25-
| ^ expected `[usize; x]`, found integer
26-
27-
error[E0308]: mismatched types
28-
--> $DIR/error_in_ty.rs:16:8
29-
|
30-
LL | impl A<2> {
31-
| ^ expected `[usize; x]`, found integer
32-
339
error[E0592]: duplicate definitions with name `B`
3410
--> $DIR/error_in_ty.rs:12:5
3511
|
@@ -39,7 +15,7 @@ LL | pub const fn B() {}
3915
LL | pub const fn B() {}
4016
| ---------------- other definition for `B`
4117

42-
error: aborting due to 5 previous errors
18+
error: aborting due to 2 previous errors
4319

44-
Some errors have detailed explanations: E0308, E0425, E0592.
45-
For more information about an error, try `rustc --explain E0308`.
20+
Some errors have detailed explanations: E0425, E0592.
21+
For more information about an error, try `rustc --explain E0425`.

tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/issue-62504.rs:18:21
3-
|
4-
LL | ArrayHolder([0; Self::SIZE])
5-
| ^^^^^^^^^^^^^^^ expected `X`, found `Self::SIZE`
6-
|
7-
= note: expected constant `X`
8-
found constant `Self::SIZE`
9-
10-
error: unconstrained generic constant
11-
--> $DIR/issue-62504.rs:18:25
12-
|
13-
LL | ArrayHolder([0; Self::SIZE])
14-
| ^^^^^^^^^^
15-
|
16-
help: try adding a `where` bound
17-
|
18-
LL | pub const fn new() -> Self where [(); Self::SIZE]: {
19-
| +++++++++++++++++++++++
20-
211
error[E0284]: type annotations needed for `ArrayHolder<_>`
222
--> $DIR/issue-62504.rs:26:9
233
|
@@ -52,7 +32,6 @@ help: consider giving `array` an explicit type, where the value of const paramet
5232
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
5333
| ++++++++++++++++
5434

55-
error: aborting due to 4 previous errors
35+
error: aborting due to 2 previous errors
5636

57-
Some errors have detailed explanations: E0284, E0308.
58-
For more information about an error, try `rustc --explain E0284`.
37+
For more information about this error, try `rustc --explain E0284`.
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
error: constant expression depends on a generic parameter
2-
--> $DIR/issue-62504.rs:18:25
3-
|
4-
LL | ArrayHolder([0; Self::SIZE])
5-
| ^^^^^^^^^^
6-
|
7-
= note: this may fail depending on what value the parameter takes
8-
9-
error[E0308]: mismatched types
10-
--> $DIR/issue-62504.rs:18:21
11-
|
12-
LL | ArrayHolder([0; Self::SIZE])
13-
| ----------- ^^^^^^^^^^^^^^^ expected `X`, found `Self::SIZE`
14-
| |
15-
| arguments to this struct are incorrect
16-
|
17-
= note: expected array `[u32; X]`
18-
found array `[u32; Self::SIZE]`
19-
note: tuple struct defined here
20-
--> $DIR/issue-62504.rs:14:8
21-
|
22-
LL | struct ArrayHolder<const X: usize>([u32; X]);
23-
| ^^^^^^^^^^^
24-
251
error[E0284]: type annotations needed for `ArrayHolder<_>`
262
--> $DIR/issue-62504.rs:26:9
273
|
@@ -56,7 +32,6 @@ help: consider giving `array` an explicit type, where the value of const paramet
5632
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
5733
| ++++++++++++++++
5834

59-
error: aborting due to 4 previous errors
35+
error: aborting due to 2 previous errors
6036

61-
Some errors have detailed explanations: E0284, E0308.
62-
For more information about an error, try `rustc --explain E0284`.
37+
For more information about this error, try `rustc --explain E0284`.

tests/ui/const-generics/issues/issue-62878.min.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ LL | fn foo<const N: usize, const A: [u8; N]>() {}
66
|
77
= note: const parameters may not be used in the type of const parameters
88

9-
error: `[u8; N]` is forbidden as the type of a const generic parameter
10-
--> $DIR/issue-62878.rs:5:33
11-
|
12-
LL | fn foo<const N: usize, const A: [u8; N]>() {}
13-
| ^^^^^^^
14-
|
15-
= note: the only supported types are integers, `bool`, and `char`
16-
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
17-
|
18-
LL + #![feature(adt_const_params)]
19-
|
20-
219
error[E0747]: type provided when a constant was expected
2210
--> $DIR/issue-62878.rs:10:11
2311
|
@@ -30,7 +18,7 @@ help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
3018
LL + #![feature(generic_arg_infer)]
3119
|
3220

33-
error: aborting due to 3 previous errors
21+
error: aborting due to 2 previous errors
3422

3523
Some errors have detailed explanations: E0747, E0770.
3624
For more information about an error, try `rustc --explain E0747`.

0 commit comments

Comments
 (0)