Skip to content

Commit c43d981

Browse files
committed
Use ConstArgKind::Path for all paths
Like in the previous commit, (most of) these changes to error output are not desired. They are merely committed temporarily to make it easier to see what's changed.
1 parent 87b1f29 commit c43d981

File tree

5 files changed

+31
-37
lines changed

5 files changed

+31
-37
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2396,9 +2396,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23962396
let maybe_res =
23972397
self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
23982398
debug!("res={:?}", maybe_res);
2399-
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
24002399
if let Some(res) = maybe_res
2401-
&& let Res::Def(DefKind::ConstParam, _) = res
2400+
&& let Res::Def(DefKind::ConstParam | DefKind::Const, _) = res
24022401
&& let ExprKind::Path(qself, path) = &expr.kind
24032402
{
24042403
let qpath = self.lower_qpath(
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/generic_const_exprs/type-alias-bounds.neg.stderr

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
error[E0277]: the trait bound `String: Copy` is not satisfied
2-
--> $DIR/type-alias-bounds.rs:23:12
3-
|
4-
LL | let _: AliasConstUnused<String>;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
6-
|
7-
note: required by a bound in `ct_unused_0::AliasConstUnused`
8-
--> $DIR/type-alias-bounds.rs:20:30
9-
|
10-
LL | type AliasConstUnused<T: Copy> = (T, I32<{ DATA }>);
11-
| ^^^^ required by this bound in `AliasConstUnused`
12-
131
error[E0277]: the trait bound `String: Copy` is not satisfied
142
--> $DIR/type-alias-bounds.rs:31:12
153
|
@@ -58,6 +46,6 @@ note: required by a bound in `AliasFnUsed`
5846
LL | type AliasFnUsed<T: Trait + Copy> = I32<{ code::<T>() }>;
5947
| ^^^^ required by this bound in `AliasFnUsed`
6048

61-
error: aborting due to 5 previous errors
49+
error: aborting due to 4 previous errors
6250

6351
For more information about this error, try `rustc --explain E0277`.

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`.

0 commit comments

Comments
 (0)