Skip to content

Commit

Permalink
Use ConstArgKind::Path for all paths
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
camelid committed Oct 1, 2024
1 parent 87b1f29 commit c43d981
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 37 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2396,9 +2396,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let maybe_res =
self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
debug!("res={:?}", maybe_res);
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
if let Some(res) = maybe_res
&& let Res::Def(DefKind::ConstParam, _) = res
&& let Res::Def(DefKind::ConstParam | DefKind::Const, _) = res
&& let ExprKind::Path(qself, path) = &expr.kind
{
let qpath = self.lower_qpath(
Expand Down
37 changes: 28 additions & 9 deletions tests/ui/const-generics/bad-generic-in-copy-impl.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
error[E0308]: mismatched types
--> $DIR/bad-generic-in-copy-impl.rs:3:13
error: the constant `1` is not of type `usize`
--> $DIR/bad-generic-in-copy-impl.rs:3:8
|
LL | x: [u8; SIZE],
| ^^^^ expected `usize`, found `u32`
| ^^^^^^^^^^ expected `usize`, found `u32`

error[E0308]: mismatched types
--> $DIR/bad-generic-in-copy-impl.rs:3:13
error[E0204]: the trait `Copy` cannot be implemented for this type
--> $DIR/bad-generic-in-copy-impl.rs:1:10
|
LL | #[derive(Copy, Clone)]
| ^^^^
LL | pub struct Foo {
LL | x: [u8; SIZE],
| ^^^^ expected `usize`, found `u32`
| ------------- this field does not implement `Copy`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: the `Copy` impl for `[u8; 1]` requires that `the constant `1` has type `usize``
--> $DIR/bad-generic-in-copy-impl.rs:3:8
|
LL | x: [u8; SIZE],
| ^^^^^^^^^^
= note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)

error: the constant `1` is not of type `usize`
--> $DIR/bad-generic-in-copy-impl.rs:3:5
|
LL | #[derive(Copy, Clone)]
| ----- in this derive macro expansion
LL | pub struct Foo {
LL | x: [u8; SIZE],
| ^^^^^^^^^^^^^ expected `usize`, found `u32`
|
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.
For more information about this error, try `rustc --explain E0204`.
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/type-alias-bounds.rs:23:12
|
LL | let _: AliasConstUnused<String>;
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound in `ct_unused_0::AliasConstUnused`
--> $DIR/type-alias-bounds.rs:20:30
|
LL | type AliasConstUnused<T: Copy> = (T, I32<{ DATA }>);
| ^^^^ required by this bound in `AliasConstUnused`

error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/type-alias-bounds.rs:31:12
|
Expand Down Expand Up @@ -58,6 +46,6 @@ note: required by a bound in `AliasFnUsed`
LL | type AliasFnUsed<T: Trait + Copy> = I32<{ code::<T>() }>;
| ^^^^ required by this bound in `AliasFnUsed`

error: aborting due to 5 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0277`.
6 changes: 0 additions & 6 deletions tests/ui/consts/const-len-underflow-separate-spans.old.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ error[E0080]: evaluation of constant value failed
LL | const LEN: usize = ONE - TWO;
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow

note: erroneous constant encountered
--> $DIR/const-len-underflow-separate-spans.rs:14:17
|
LL | let a: [i8; LEN] = unimplemented!();
| ^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0080`.
8 changes: 1 addition & 7 deletions tests/ui/consts/issue-39974.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ help: use a float literal
LL | const LENGTH: f64 = 2.0;
| ++

error[E0308]: mismatched types
--> $DIR/issue-39974.rs:5:19
|
LL | f: [[f64; 2]; LENGTH],
| ^^^^^^ expected `usize`, found `f64`

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

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

0 comments on commit c43d981

Please sign in to comment.