rust/tests/ui/variance
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
..
variance-associated-consts.rs Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
variance-associated-consts.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
variance-associated-types2.rs
variance-associated-types2.stderr
variance-associated-types.rs
variance-associated-types.stderr
variance-btree-invariant-types.rs
variance-btree-invariant-types.stderr
variance-cell-is-invariant.rs
variance-cell-is-invariant.stderr
variance-contravariant-arg-object.rs
variance-contravariant-arg-object.stderr
variance-contravariant-arg-trait-match.rs
variance-contravariant-arg-trait-match.stderr
variance-contravariant-self-trait-match.rs
variance-contravariant-self-trait-match.stderr
variance-covariant-arg-object.rs
variance-covariant-arg-object.stderr
variance-covariant-arg-trait-match.rs
variance-covariant-arg-trait-match.stderr
variance-covariant-self-trait-match.rs
variance-covariant-self-trait-match.stderr
variance-intersection-of-ref-and-opt-ref.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
variance-invariant-arg-object.rs
variance-invariant-arg-object.stderr
variance-invariant-arg-trait-match.rs
variance-invariant-arg-trait-match.stderr
variance-invariant-self-trait-match.rs
variance-invariant-self-trait-match.stderr
variance-issue-20533.rs
variance-issue-20533.stderr
variance-iterators-in-libcore.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
variance-object-types.rs
variance-object-types.stderr
variance-regions-direct.rs Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
variance-regions-direct.stderr Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" 2024-03-11 21:28:16 +00:00
variance-regions-indirect.rs Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
variance-regions-indirect.stderr Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" 2024-03-11 21:28:16 +00:00
variance-regions-unused-direct.rs
variance-regions-unused-direct.stderr
variance-regions-unused-indirect.rs
variance-regions-unused-indirect.stderr
variance-trait-bounds.rs Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
variance-trait-bounds.stderr Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" 2024-03-11 21:28:16 +00:00
variance-trait-matching.rs
variance-trait-matching.stderr
variance-trait-object-bound.rs
variance-trait-object-bound.stderr
variance-types-bounds.rs
variance-types-bounds.stderr
variance-types.rs
variance-types.stderr
variance-unused-region-param.rs
variance-unused-region-param.stderr
variance-unused-type-param.rs
variance-unused-type-param.stderr
variance-use-contravariant-struct-1.rs
variance-use-contravariant-struct-1.stderr
variance-use-contravariant-struct-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
variance-use-covariant-struct-1.rs
variance-use-covariant-struct-1.stderr
variance-use-covariant-struct-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
variance-use-invariant-struct-1.rs
variance-use-invariant-struct-1.stderr