File tree Expand file tree Collapse file tree 9 files changed +96
-32
lines changed
src/test/ui/consts/rfc-2203-const-array-repeat-exprs Expand file tree Collapse file tree 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 11error[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
33 |
44LL | let arr: [Option<Bar>; 2] = [x; 2];
55 | ^^^^^^ 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];
99 = note: the `Copy` trait is required because the repeated element will be copied
1010
1111error[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
1313 |
1414LL | let arr: [Option<Bar>; 2] = [x; 2];
1515 | ^^^^^^ 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
22// compile-flags: -Z borrowck=migrate
3- #![ feature( constants_in_array_repeat_expressions) ]
3+ // ignore-compare-mode-nll
4+ #![ feature( const_in_array_repeat_expressions) ]
45#![ allow( warnings) ]
56
67// Some type that is not copyable.
@@ -83,12 +84,6 @@ mod non_constants {
8384 let arr: [ Option < Bar > ; 1 ] = [ x; 1 ] ;
8485 }
8586
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-
9287 fn no_impl_copy_value_no_elements ( ) {
9388 let x = Some ( Bar ) ;
9489 let arr: [ Option < Bar > ; 0 ] = [ x; 0 ] ;
@@ -99,12 +94,6 @@ mod non_constants {
9994 let arr: [ Option < Bar > ; 1 ] = [ x; 1 ] ;
10095 }
10196
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-
10897 fn impl_copy_empty_value_no_elements ( ) {
10998 let x: Option < u32 > = None ;
11099 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 11error[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
33 |
44LL | let arr: [Option<Bar>; 2] = [x; 2];
55 | ^^^^^^ 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];
99 = note: the `Copy` trait is required because the repeated element will be copied
1010
1111error[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
1313 |
1414LL | let arr: [Option<Bar>; 2] = [x; 2];
1515 | ^^^^^^ 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
23#![ allow( warnings) ]
3- #![ feature( constants_in_array_repeat_expressions , nll) ]
4+ #![ feature( const_in_array_repeat_expressions , nll) ]
45
56// Some type that is not copyable.
67struct Bar ;
@@ -82,12 +83,6 @@ mod non_constants {
8283 let arr: [ Option < Bar > ; 1 ] = [ x; 1 ] ;
8384 }
8485
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-
9186 fn no_impl_copy_value_no_elements ( ) {
9287 let x = Some ( Bar ) ;
9388 let arr: [ Option < Bar > ; 0 ] = [ x; 0 ] ;
@@ -98,12 +93,6 @@ mod non_constants {
9893 let arr: [ Option < Bar > ; 1 ] = [ x; 1 ] ;
9994 }
10095
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-
10796 fn impl_copy_empty_value_no_elements ( ) {
10897 let x: Option < u32 > = None ;
10998 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