rust/tests/ui/specialization
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
ctfe [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
defaultimpl Provide structured suggestion for #![feature(foo)] 2024-03-18 16:08:58 +00:00
min_specialization [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
soundness [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
assoc-ty-graph-cycle.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
assoc-ty-graph-cycle.stderr
const_trait_impl.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
const_trait_impl.stderr Provide structured suggestion for #![feature(foo)] 2024-03-18 16:08:58 +00:00
cross-crate-defaults.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cross-crate-defaults.stderr
default-associated-type-bound-1.rs
default-associated-type-bound-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
default-associated-type-bound-2.rs
default-associated-type-bound-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
default-generic-associated-type-bound.rs
default-generic-associated-type-bound.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-33017.rs
issue-33017.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-35376.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-35376.stderr
issue-36804.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-36804.stderr
issue-38091-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-38091-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-38091.rs
issue-38091.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-39448.rs
issue-39448.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-39618.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-39618.stderr
issue-40582.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-43037.current.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-43037.negative.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-43037.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-44861.rs
issue-44861.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-45814.current.stderr Do not assemble candidates for default impls 2024-02-13 19:20:13 +00:00
issue-45814.negative.stderr Do not assemble candidates for default impls 2024-02-13 19:20:13 +00:00
issue-45814.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-50452-fail.rs
issue-50452-fail.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-50452.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-50452.stderr
issue-51892.rs
issue-51892.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
issue-52050.rs
issue-52050.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-59435.rs
issue-59435.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-63716-parse-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-63716-parse-async.stderr
issue-68830-spurious-diagnostics.rs
issue-68830-spurious-diagnostics.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-70442.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-70442.stderr
issue-111232.rs
issue-111232.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
non-defaulted-item-fail.rs
non-defaulted-item-fail.stderr
README-rpass.md
README.md
specialization-allowed-cross-crate.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-allowed-cross-crate.stderr
specialization-assoc-fns.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-assoc-fns.stderr
specialization-basics.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-basics.stderr
specialization-cross-crate-no-gate.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-cross-crate.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-cross-crate.stderr
specialization-default-items-drop-coherence.coherence.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
specialization-default-items-drop-coherence.next.stderr Stop bailing out from compilation just because there were incoherent traits 2024-02-05 10:17:31 +00:00
specialization-default-items-drop-coherence.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-default-methods.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-default-methods.stderr
specialization-default-projection.rs
specialization-default-projection.stderr
specialization-default-types.rs
specialization-default-types.stderr
specialization-feature-gate-default.rs
specialization-feature-gate-default.stderr Bless tests 2024-01-13 12:46:58 -05:00
specialization-feature-gate-overlap.rs
specialization-feature-gate-overlap.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
specialization-no-default.rs
specialization-no-default.stderr
specialization-on-projection.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-on-projection.stderr
specialization-out-of-order.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-out-of-order.stderr
specialization-overlap-hygiene.rs
specialization-overlap-hygiene.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
specialization-overlap-negative.rs
specialization-overlap-negative.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
specialization-overlap-projection.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-overlap-projection.stderr
specialization-overlap.rs
specialization-overlap.stderr
specialization-polarity.rs
specialization-polarity.stderr
specialization-projection-alias.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-projection-alias.stderr
specialization-projection.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-projection.stderr
specialization-supertraits.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-supertraits.stderr
specialization-translate-projections-with-lifetimes.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-translate-projections-with-lifetimes.stderr
specialization-translate-projections-with-params.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-translate-projections-with-params.stderr
specialization-translate-projections.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
specialization-translate-projections.stderr
transmute-specialization.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
transmute-specialization.stderr

This directory contains the test for incorrect usage of specialization that should lead to compile failure. Those tests break down into a few categories: