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 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
complex-generic-default-expr.min.stderr generic_const_exprs: suggest to add the feature, not use it 2023-11-30 20:59:51 +01:00
complex-generic-default-expr.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
complex-unord-param.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
const-default.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
const-param-as-default-value.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
const-param-in-ty-defaults.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
default-annotation.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
default-const-param-cannot-reference-self.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
default-const-param-cannot-reference-self.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
default-on-impl.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
default-on-impl.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
default-param-wf-concrete.next.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
default-param-wf-concrete.old.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
default-param-wf-concrete.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
doesnt_infer.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
doesnt_infer.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
external.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
forward-declared.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
forward-declared.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-expr-default-concrete.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-expr-default-concrete.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
generic-expr-default-mismatched-types.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-expr-default-mismatched-types.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
generic-expr-default.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-expr-default.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
intermixed-lifetime.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
intermixed-lifetime.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mismatch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mismatch.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
mismatched_ty_const_in_trait_impl.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
mismatched_ty_const_in_trait_impl.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
param-order-err-pretty-prints-default.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
param-order-err-pretty-prints-default.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
pretty-printing-ast.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
pretty-printing-ast.stdout [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
repr-c-issue-82792.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
rp_impl_trait_fail.rs Remove a has_errors check that only hides errors after unrelated items have errored. 2024-01-31 16:51:42 +00:00
rp_impl_trait_fail.stderr Remove a has_errors check that only hides errors after unrelated items have errored. 2024-01-31 16:51:42 +00:00
rp_impl_trait.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
self-referential.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
self-referential.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
simple-defaults.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
trait_object_lt_defaults.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
trait_objects_fail.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
trait_objects_fail.stderr Note base types of coercion 2023-05-12 00:10:52 +00:00
trait_objects.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
type-default-const-param-name.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
wfness.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
wfness.stderr Specify what 'this' actually is 2023-02-21 05:21:07 +00:00
wrong-order.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
wrong-order.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00