diff options
| author | David Wood <david@davidtw.co> | 2019-06-13 17:30:49 +0100 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2019-07-07 20:23:31 +0100 |
| commit | 4b1bc2ded91915e232c38cc503b5f110556cf719 (patch) | |
| tree | 7b4f9758046afa9a8019fe39f93a7d09f7435708 /src | |
| parent | a655438988c5f7d100a5423752b7ae0287d582fd (diff) | |
| download | rust-4b1bc2ded91915e232c38cc503b5f110556cf719.tar.gz rust-4b1bc2ded91915e232c38cc503b5f110556cf719.zip | |
tests: Add tests that use const fns.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-fns.rs | 26 | ||||
| -rw-r--r-- | src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-fns.stderr | 13 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-fns.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-fns.rs new file mode 100644 index 00000000000..68a9227dea9 --- /dev/null +++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-fns.rs @@ -0,0 +1,26 @@ +// ignore-tidy-linelength +// ignore-compare-mode-nll +#![feature(const_in_array_repeat_expressions, nll)] +#![allow(warnings)] + +// Some type that is not copyable. +struct Bar; + +const fn type_no_copy() -> Option<Bar> { + None +} + +const fn type_copy() -> u32 { + 3 +} + +fn no_copy() { + const ARR: [Option<Bar>; 2] = [type_no_copy(); 2]; + //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277] +} + +fn copy() { + const ARR: [u32; 2] = [type_copy(); 2]; +} + +fn main() {} diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-fns.stderr b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-fns.stderr new file mode 100644 index 00000000000..82272af958a --- /dev/null +++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-fns.stderr @@ -0,0 +1,13 @@ +error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied + --> $DIR/const-fns.rs:18:35 + | +LL | const ARR: [Option<Bar>; 2] = [type_no_copy(); 2]; + | ^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>` + | + = help: the following implementations were found: + <std::option::Option<T> as std::marker::Copy> + = note: the `Copy` trait is required because the repeated element will be copied + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
