rust/tests/ui/generic-const-items
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
..
associated-const-equality.rs
basic.rs
compare-impl-item.rs
compare-impl-item.stderr
const-trait-impl.rs
duplicate-where-clause.rs
duplicate-where-clause.stderr
elided-lifetimes.rs
elided-lifetimes.stderr
evaluatable-bounds.fixed
evaluatable-bounds.rs
evaluatable-bounds.stderr
evaluatable-bounds.unconstrained.stderr
feature-gate-generic_const_items.rs
feature-gate-generic_const_items.stderr
inference-failure.rs
inference-failure.stderr
misplaced-where-clause.fixed
misplaced-where-clause.rs
misplaced-where-clause.stderr
parameter-defaults.rs
parameter-defaults.stderr
recursive.rs
reference-outlives-referent.rs
reference-outlives-referent.stderr
trivially-unsatisfied-bounds-0.rs
trivially-unsatisfied-bounds-0.stderr
trivially-unsatisfied-bounds-1.rs
trivially-unsatisfied-bounds-1.stderr
unsatisfied-bounds.rs
unsatisfied-bounds.stderr
unsatisfied-evaluatable-bounds.rs
unsatisfied-evaluatable-bounds.stderr
unsatisfied-outlives-bounds.rs
unsatisfied-outlives-bounds.stderr