rust/tests/ui/const-generics/defaults
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
..
auxiliary
complex-generic-default-expr.min.stderr
complex-generic-default-expr.rs
complex-unord-param.rs
const-default.rs
const-param-as-default-value.rs
const-param-in-ty-defaults.rs
default-annotation.rs
default-const-param-cannot-reference-self.rs
default-const-param-cannot-reference-self.stderr
default-on-impl.rs
default-on-impl.stderr
default-param-wf-concrete.next.stderr
default-param-wf-concrete.old.stderr
default-param-wf-concrete.rs
doesnt_infer.rs
doesnt_infer.stderr
external.rs
forward-declared.rs
forward-declared.stderr
generic-expr-default-concrete.rs
generic-expr-default-concrete.stderr
generic-expr-default-mismatched-types.rs
generic-expr-default-mismatched-types.stderr
generic-expr-default.rs
generic-expr-default.stderr
intermixed-lifetime.rs
intermixed-lifetime.stderr
mismatch.rs
mismatch.stderr
mismatched_ty_const_in_trait_impl.rs
mismatched_ty_const_in_trait_impl.stderr
param-order-err-pretty-prints-default.rs
param-order-err-pretty-prints-default.stderr
pretty-printing-ast.rs
pretty-printing-ast.stdout
repr-c-issue-82792.rs
rp_impl_trait_fail.rs
rp_impl_trait_fail.stderr
rp_impl_trait.rs
self-referential.rs
self-referential.stderr
simple-defaults.rs
trait_object_lt_defaults.rs
trait_objects_fail.rs
trait_objects_fail.stderr
trait_objects.rs
type-default-const-param-name.rs
wfness.rs
wfness.stderr
wrong-order.rs
wrong-order.stderr