diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-07-11 15:19:30 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-11 15:19:30 +0530 |
| commit | 92b8adf8e06594cb9b3477526e31fdba74ac63ad (patch) | |
| tree | da1738011e10dadc441097abe1b08ad1b6f05e4d /src | |
| parent | 943152008fbea871013bec69c85baae8356a485d (diff) | |
| parent | a1634642e079d4517e31a75fa002ea0496148cda (diff) | |
| download | rust-92b8adf8e06594cb9b3477526e31fdba74ac63ad.tar.gz rust-92b8adf8e06594cb9b3477526e31fdba74ac63ad.zip | |
Rollup merge of #98907 - compiler-errors:plz-no-float, r=oli-obk
Deny float const params even when `adt_const_params` is enabled Supersedes #98825 Fixes #98813 r? ``@oli-obk``
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/const-generics/float-generic.adt_const_params.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/const-generics/float-generic.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/const-generics/float-generic.simple.stderr | 11 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/float-generic.adt_const_params.stderr b/src/test/ui/const-generics/float-generic.adt_const_params.stderr new file mode 100644 index 00000000000..fef5ef0d1fa --- /dev/null +++ b/src/test/ui/const-generics/float-generic.adt_const_params.stderr @@ -0,0 +1,11 @@ +error[E0741]: `f32` is forbidden as the type of a const generic parameter + --> $DIR/float-generic.rs:5:17 + | +LL | fn foo<const F: f32>() {} + | ^^^ + | + = note: floats do not derive `Eq` or `Ord`, which are required for const parameters + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/float-generic.rs b/src/test/ui/const-generics/float-generic.rs new file mode 100644 index 00000000000..b72059b5b1c --- /dev/null +++ b/src/test/ui/const-generics/float-generic.rs @@ -0,0 +1,12 @@ +// revisions: simple adt_const_params +#![cfg_attr(adt_const_params, feature(adt_const_params))] +#![cfg_attr(adt_const_params, allow(incomplete_features))] + +fn foo<const F: f32>() {} +//~^ ERROR `f32` is forbidden as the type of a const generic parameter + +const C: f32 = 1.0; + +fn main() { + foo::<C>(); +} diff --git a/src/test/ui/const-generics/float-generic.simple.stderr b/src/test/ui/const-generics/float-generic.simple.stderr new file mode 100644 index 00000000000..89ca36b0f63 --- /dev/null +++ b/src/test/ui/const-generics/float-generic.simple.stderr @@ -0,0 +1,11 @@ +error: `f32` is forbidden as the type of a const generic parameter + --> $DIR/float-generic.rs:5:17 + | +LL | fn foo<const F: f32>() {} + | ^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + |
