File tree 9 files changed +96
-32
lines changed
src/test/ui/consts/rfc-2203-const-array-repeat-exprs
9 files changed +96
-32
lines changed Original file line number Diff line number Diff line change
1
+ // ignore-tidy-linelength
2
+ // ignore-compare-mode-nll
3
+ // compile-flags: -Z borrowck=migrate
4
+ #![ feature( const_in_array_repeat_expressions) ]
5
+ #![ allow( warnings) ]
6
+
7
+ // Some type that is not copyable.
8
+ struct Bar ;
9
+
10
+ mod non_constants {
11
+ use Bar ;
12
+
13
+ fn no_impl_copy_empty_value_multiple_elements ( ) {
14
+ let x = None ;
15
+ let arr: [ Option < Bar > ; 2 ] = [ x; 2 ] ;
16
+ //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
17
+ }
18
+
19
+ fn no_impl_copy_value_multiple_elements ( ) {
20
+ let x = Some ( Bar ) ;
21
+ let arr: [ Option < Bar > ; 2 ] = [ x; 2 ] ;
22
+ //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
23
+ }
24
+ }
25
+
26
+ fn main ( ) { }
Original file line number Diff line number Diff line change 1
1
error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
2
- --> $DIR/nll-borrowck .rs:87 :37
2
+ --> $DIR/migrate-fail .rs:15 :37
3
3
|
4
4
LL | let arr: [Option<Bar>; 2] = [x; 2];
5
5
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
@@ -9,7 +9,7 @@ LL | let arr: [Option<Bar>; 2] = [x; 2];
9
9
= note: the `Copy` trait is required because the repeated element will be copied
10
10
11
11
error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
12
- --> $DIR/nll-borrowck .rs:103 :37
12
+ --> $DIR/migrate-fail .rs:21 :37
13
13
|
14
14
LL | let arr: [Option<Bar>; 2] = [x; 2];
15
15
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
Original file line number Diff line number Diff line change 1
- // ignore-compile-mode-nll
1
+ // check-pass
2
2
// compile-flags: -Z borrowck=migrate
3
- #![ feature( constants_in_array_repeat_expressions) ]
3
+ // ignore-compare-mode-nll
4
+ #![ feature( const_in_array_repeat_expressions) ]
4
5
#![ allow( warnings) ]
5
6
6
7
// Some type that is not copyable.
@@ -83,12 +84,6 @@ mod non_constants {
83
84
let arr: [ Option < Bar > ; 1 ] = [ x; 1 ] ;
84
85
}
85
86
86
- fn no_impl_copy_empty_value_multiple_elements ( ) {
87
- let x = None ;
88
- let arr: [ Option < Bar > ; 2 ] = [ x; 2 ] ;
89
- //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
90
- }
91
-
92
87
fn no_impl_copy_value_no_elements ( ) {
93
88
let x = Some ( Bar ) ;
94
89
let arr: [ Option < Bar > ; 0 ] = [ x; 0 ] ;
@@ -99,12 +94,6 @@ mod non_constants {
99
94
let arr: [ Option < Bar > ; 1 ] = [ x; 1 ] ;
100
95
}
101
96
102
- fn no_impl_copy_value_multiple_elements ( ) {
103
- let x = Some ( Bar ) ;
104
- let arr: [ Option < Bar > ; 2 ] = [ x; 2 ] ;
105
- //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
106
- }
107
-
108
97
fn impl_copy_empty_value_no_elements ( ) {
109
98
let x: Option < u32 > = None ;
110
99
let arr: [ Option < u32 > ; 0 ] = [ x; 0 ] ;
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
+ mod non_constants {
10
+ use Bar ;
11
+
12
+ fn no_impl_copy_empty_value_multiple_elements ( ) {
13
+ let x = None ;
14
+ let arr: [ Option < Bar > ; 2 ] = [ x; 2 ] ;
15
+ //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
16
+ }
17
+
18
+ fn no_impl_copy_value_multiple_elements ( ) {
19
+ let x = Some ( Bar ) ;
20
+ let arr: [ Option < Bar > ; 2 ] = [ x; 2 ] ;
21
+ //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
22
+ }
23
+ }
24
+
25
+ fn main ( ) { }
Original file line number Diff line number Diff line change 1
1
error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
2
- --> $DIR/migrate-borrowck .rs:88 :37
2
+ --> $DIR/nll-fail .rs:14 :37
3
3
|
4
4
LL | let arr: [Option<Bar>; 2] = [x; 2];
5
5
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
@@ -9,7 +9,7 @@ LL | let arr: [Option<Bar>; 2] = [x; 2];
9
9
= note: the `Copy` trait is required because the repeated element will be copied
10
10
11
11
error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
12
- --> $DIR/migrate-borrowck .rs:104 :37
12
+ --> $DIR/nll-fail .rs:20 :37
13
13
|
14
14
LL | let arr: [Option<Bar>; 2] = [x; 2];
15
15
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
Original file line number Diff line number Diff line change 1
- // ignore-compile-mode-nll
1
+ // check-pass
2
+ // ignore-compare-mode-nll
2
3
#![ allow( warnings) ]
3
- #![ feature( constants_in_array_repeat_expressions , nll) ]
4
+ #![ feature( const_in_array_repeat_expressions , nll) ]
4
5
5
6
// Some type that is not copyable.
6
7
struct Bar ;
@@ -82,12 +83,6 @@ mod non_constants {
82
83
let arr: [ Option < Bar > ; 1 ] = [ x; 1 ] ;
83
84
}
84
85
85
- fn no_impl_copy_empty_value_multiple_elements ( ) {
86
- let x = None ;
87
- let arr: [ Option < Bar > ; 2 ] = [ x; 2 ] ;
88
- //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
89
- }
90
-
91
86
fn no_impl_copy_value_no_elements ( ) {
92
87
let x = Some ( Bar ) ;
93
88
let arr: [ Option < Bar > ; 0 ] = [ x; 0 ] ;
@@ -98,12 +93,6 @@ mod non_constants {
98
93
let arr: [ Option < Bar > ; 1 ] = [ x; 1 ] ;
99
94
}
100
95
101
- fn no_impl_copy_value_multiple_elements ( ) {
102
- let x = Some ( Bar ) ;
103
- let arr: [ Option < Bar > ; 2 ] = [ x; 2 ] ;
104
- //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
105
- }
106
-
107
96
fn impl_copy_empty_value_no_elements ( ) {
108
97
let x: Option < u32 > = None ;
109
98
let arr: [ Option < u32 > ; 0 ] = [ x; 0 ] ;
Original file line number Diff line number Diff line change
1
+ // run-pass
2
+ #![ feature( const_in_array_repeat_expressions) ]
3
+
4
+ #[ derive( Debug , Eq , PartialEq ) ]
5
+ struct Bar ;
6
+
7
+ fn main ( ) {
8
+ const FOO : Option < Bar > = None ;
9
+ const ARR : [ Option < Bar > ; 2 ] = [ FOO ; 2 ] ;
10
+
11
+ assert_eq ! ( ARR , [ None :: <Bar >, None :: <Bar >] ) ;
12
+ }
Original file line number Diff line number Diff line change
1
+ // ignore-tidy-linelength
2
+ #![ feature( const_in_array_repeat_expressions) ]
3
+
4
+ #[ derive( Copy , Clone ) ]
5
+ struct Foo < T > ( T ) ;
6
+
7
+ fn main ( ) {
8
+ [ Foo ( String :: new ( ) ) ; 4 ] ;
9
+ //~^ ERROR the trait bound `Foo<std::string::String>: std::marker::Copy` is not satisfied [E0277]
10
+ }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `Foo<std::string::String>: std::marker::Copy` is not satisfied
2
+ --> $DIR/trait-error.rs:8:5
3
+ |
4
+ LL | [Foo(String::new()); 4];
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `Foo<std::string::String>`
6
+ |
7
+ = help: the following implementations were found:
8
+ <Foo<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