diff options
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 + |
