File tree 2 files changed +39
-0
lines changed
src/test/ui/consts/rfc-2203-const-array-repeat-exprs
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ // ignore-tidy-linelength
2
+ // ignore-compare-mode-nll
3
+ #![ feature( const_in_array_repeat_expressions, nll) ]
4
+ #![ allow( warnings) ]
5
+
6
+ // Some type that is not copyable.
7
+ struct Bar ;
8
+
9
+ const fn type_no_copy ( ) -> Option < Bar > {
10
+ None
11
+ }
12
+
13
+ const fn type_copy ( ) -> u32 {
14
+ 3
15
+ }
16
+
17
+ fn no_copy ( ) {
18
+ const ARR : [ Option < Bar > ; 2 ] = [ type_no_copy ( ) ; 2 ] ;
19
+ //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
20
+ }
21
+
22
+ fn copy ( ) {
23
+ const ARR : [ u32 ; 2 ] = [ type_copy ( ) ; 2 ] ;
24
+ }
25
+
26
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
2
+ --> $DIR/const-fns.rs:18:35
3
+ |
4
+ LL | const ARR: [Option<Bar>; 2] = [type_no_copy(); 2];
5
+ | ^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
6
+ |
7
+ = help: the following implementations were found:
8
+ <std::option::Option<T> as std::marker::Copy>
9
+ = note: the `Copy` trait is required because the repeated element will be copied
10
+
11
+ error: aborting due to previous error
12
+
13
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments