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

+1-8
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,
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

+1-25
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

+2-12
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

+2-12
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

+1-11
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

+3-27
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

+2-23
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`.
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

+1-13
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`.

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

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

9-
error: `[u8; LEN]` is forbidden as the type of a const generic parameter
10-
--> $DIR/issue-71169.rs:5:38
11-
|
12-
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
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: aborting due to 2 previous errors
9+
error: aborting due to 1 previous error
2210

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

tests/ui/const-generics/not_wf_param_in_rpitit.stderr

+1-24
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,6 @@ LL | trait Trait<const N: dyn Trait = bar> {
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919
= 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
2020

21-
error[E0038]: the trait `Trait` cannot be made into an object
22-
--> $DIR/not_wf_param_in_rpitit.rs:3:22
23-
|
24-
LL | trait Trait<const N: dyn Trait = bar> {
25-
| ^^^^^^^^^ `Trait` cannot be made into an object
26-
|
27-
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
28-
--> $DIR/not_wf_param_in_rpitit.rs:9:14
29-
|
30-
LL | trait Trait<const N: dyn Trait = bar> {
31-
| ----- this trait cannot be made into an object...
32-
...
33-
LL | async fn a() {}
34-
| ^ ...because associated function `a` has no `self` parameter
35-
help: consider turning `a` into a method by giving it a `&self` argument
36-
|
37-
LL | async fn a(&self) {}
38-
| +++++
39-
help: alternatively, consider constraining `a` so it does not apply to trait objects
40-
|
41-
LL | async fn a() where Self: Sized {}
42-
| +++++++++++++++++
43-
4421
error[E0038]: the trait `Trait` cannot be made into an object
4522
--> $DIR/not_wf_param_in_rpitit.rs:3:13
4623
|
@@ -88,7 +65,7 @@ help: alternatively, consider constraining `a` so it does not apply to trait obj
8865
LL | async fn a() where Self: Sized {}
8966
| +++++++++++++++++
9067

91-
error: aborting due to 5 previous errors
68+
error: aborting due to 4 previous errors
9269

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

tests/ui/consts/const-len-underflow-separate-spans.old.stderr

-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error[E0080]: evaluation of constant value failed
44
LL | const LEN: usize = ONE - TWO;
55
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
66

7-
note: erroneous constant encountered
8-
--> $DIR/const-len-underflow-separate-spans.rs:14:17
9-
|
10-
LL | let a: [i8; LEN] = unimplemented!();
11-
| ^^^
12-
137
error: aborting due to 1 previous error
148

159
For more information about this error, try `rustc --explain E0080`.

tests/ui/consts/issue-39974.stderr

+1-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ help: use a float literal
99
LL | const LENGTH: f64 = 2.0;
1010
| ++
1111

12-
error[E0308]: mismatched types
13-
--> $DIR/issue-39974.rs:5:19
14-
|
15-
LL | f: [[f64; 2]; LENGTH],
16-
| ^^^^^^ expected `usize`, found `f64`
17-
18-
error: aborting due to 2 previous errors
12+
error: aborting due to 1 previous error
1913

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

tests/ui/extern/extern-static-size-overflow.stderr

+1-13
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,5 @@ error: extern static is too large for the target architecture
44
LL | static BAZ: [u8; max_size()];
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

7-
error: extern static is too large for the target architecture
8-
--> $DIR/extern-static-size-overflow.rs:21:5
9-
|
10-
LL | static UWU: [usize; usize::MAX];
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
13-
error: extern static is too large for the target architecture
14-
--> $DIR/extern-static-size-overflow.rs:22:5
15-
|
16-
LL | static A: ReallyBig;
17-
| ^^^^^^^^^^^^^^^^^^^
18-
19-
error: aborting due to 3 previous errors
7+
error: aborting due to 1 previous error
208

0 commit comments

Comments
 (0)