1
Fork 0
Commit graph

9 commits

Author SHA1 Message Date
Gary Guo
cfee72aa24 Fix tests and bless 2024-04-24 13:12:33 +01:00
Esteban Küber
6b24fdf811 Provide structured suggestion for unconstrained generic constant
```
error: unconstrained generic constant
  --> $DIR/const-argument-if-length.rs:18:10
   |
LL |     pad: [u8; is_zst::<T>()],
   |          ^^^^^^^^^^^^^^^^^^^
   |
help: try adding a `where` bound
   |
LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: {
   |                                   ++++++++++++++++++++++++++
```

Detect when the constant expression isn't `usize` and suggest casting:

```
error: unconstrained generic constant
 --> f300.rs:6:10
  |
6 |     bb::<{!N}>();
  |          ^^^^
-Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs:3539:36
  |
help: try adding a `where` bound
  |
5 | fn b<const N: bool>() where [(); {!N} as usize]: {
  |                       ++++++++++++++++++++++++++
```

Fix #122395.
2024-03-21 00:03:59 +00:00
will
7c4b07d5e8 added pretty_print_const_expr 2024-03-17 01:38:45 +11:00
Shoyu Vanilla
6721b392e9 Replace TypeWalker usage with TypeVisitor 2024-03-08 20:49:03 +09:00
许杰友 Jieyou Xu (Joe)
ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
Lenko Donchev
69a2bd6c04 report_not_const_evaluatable_error to avoid ICEing on ConstKind::Expr 2023-12-09 10:19:19 -06:00
Boxy
a85b0101e6 make relate's const ty assertion use semantic equality 2023-02-11 23:05:16 +00:00
Boxy
d85d906f8c emit ConstEquate in TypeRelating<D> 2023-02-05 07:24:54 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00