tests: Update and add tests for RFC 2203.
This commit is contained in:
parent
813c994a75
commit
a655438988
9 changed files with 96 additions and 32 deletions
|
@ -0,0 +1,26 @@
|
|||
// ignore-tidy-linelength
|
||||
// ignore-compare-mode-nll
|
||||
// compile-flags: -Z borrowck=migrate
|
||||
#![feature(const_in_array_repeat_expressions)]
|
||||
#![allow(warnings)]
|
||||
|
||||
// Some type that is not copyable.
|
||||
struct Bar;
|
||||
|
||||
mod non_constants {
|
||||
use Bar;
|
||||
|
||||
fn no_impl_copy_empty_value_multiple_elements() {
|
||||
let x = None;
|
||||
let arr: [Option<Bar>; 2] = [x; 2];
|
||||
//~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn no_impl_copy_value_multiple_elements() {
|
||||
let x = Some(Bar);
|
||||
let arr: [Option<Bar>; 2] = [x; 2];
|
||||
//~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
|
||||
--> $DIR/nll-borrowck.rs:87:37
|
||||
--> $DIR/migrate-fail.rs:15:37
|
||||
|
|
||||
LL | let arr: [Option<Bar>; 2] = [x; 2];
|
||||
| ^^^^^^ 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];
|
|||
= note: the `Copy` trait is required because the repeated element will be copied
|
||||
|
||||
error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
|
||||
--> $DIR/nll-borrowck.rs:103:37
|
||||
--> $DIR/migrate-fail.rs:21:37
|
||||
|
|
||||
LL | let arr: [Option<Bar>; 2] = [x; 2];
|
||||
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
|
|
@ -1,6 +1,7 @@
|
|||
// ignore-compile-mode-nll
|
||||
// check-pass
|
||||
// compile-flags: -Z borrowck=migrate
|
||||
#![feature(constants_in_array_repeat_expressions)]
|
||||
// ignore-compare-mode-nll
|
||||
#![feature(const_in_array_repeat_expressions)]
|
||||
#![allow(warnings)]
|
||||
|
||||
// Some type that is not copyable.
|
||||
|
@ -83,12 +84,6 @@ mod non_constants {
|
|||
let arr: [Option<Bar>; 1] = [x; 1];
|
||||
}
|
||||
|
||||
fn no_impl_copy_empty_value_multiple_elements() {
|
||||
let x = None;
|
||||
let arr: [Option<Bar>; 2] = [x; 2];
|
||||
//~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn no_impl_copy_value_no_elements() {
|
||||
let x = Some(Bar);
|
||||
let arr: [Option<Bar>; 0] = [x; 0];
|
||||
|
@ -99,12 +94,6 @@ mod non_constants {
|
|||
let arr: [Option<Bar>; 1] = [x; 1];
|
||||
}
|
||||
|
||||
fn no_impl_copy_value_multiple_elements() {
|
||||
let x = Some(Bar);
|
||||
let arr: [Option<Bar>; 2] = [x; 2];
|
||||
//~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn impl_copy_empty_value_no_elements() {
|
||||
let x: Option<u32> = None;
|
||||
let arr: [Option<u32>; 0] = [x; 0];
|
|
@ -0,0 +1,25 @@
|
|||
// ignore-tidy-linelength
|
||||
// ignore-compare-mode-nll
|
||||
#![feature(const_in_array_repeat_expressions, nll)]
|
||||
#![allow(warnings)]
|
||||
|
||||
// Some type that is not copyable.
|
||||
struct Bar;
|
||||
|
||||
mod non_constants {
|
||||
use Bar;
|
||||
|
||||
fn no_impl_copy_empty_value_multiple_elements() {
|
||||
let x = None;
|
||||
let arr: [Option<Bar>; 2] = [x; 2];
|
||||
//~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn no_impl_copy_value_multiple_elements() {
|
||||
let x = Some(Bar);
|
||||
let arr: [Option<Bar>; 2] = [x; 2];
|
||||
//~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
|
||||
--> $DIR/migrate-borrowck.rs:88:37
|
||||
--> $DIR/nll-fail.rs:14:37
|
||||
|
|
||||
LL | let arr: [Option<Bar>; 2] = [x; 2];
|
||||
| ^^^^^^ 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];
|
|||
= note: the `Copy` trait is required because the repeated element will be copied
|
||||
|
||||
error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
|
||||
--> $DIR/migrate-borrowck.rs:104:37
|
||||
--> $DIR/nll-fail.rs:20:37
|
||||
|
|
||||
LL | let arr: [Option<Bar>; 2] = [x; 2];
|
||||
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
|
|
@ -1,6 +1,7 @@
|
|||
// ignore-compile-mode-nll
|
||||
// check-pass
|
||||
// ignore-compare-mode-nll
|
||||
#![allow(warnings)]
|
||||
#![feature(constants_in_array_repeat_expressions, nll)]
|
||||
#![feature(const_in_array_repeat_expressions, nll)]
|
||||
|
||||
// Some type that is not copyable.
|
||||
struct Bar;
|
||||
|
@ -82,12 +83,6 @@ mod non_constants {
|
|||
let arr: [Option<Bar>; 1] = [x; 1];
|
||||
}
|
||||
|
||||
fn no_impl_copy_empty_value_multiple_elements() {
|
||||
let x = None;
|
||||
let arr: [Option<Bar>; 2] = [x; 2];
|
||||
//~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn no_impl_copy_value_no_elements() {
|
||||
let x = Some(Bar);
|
||||
let arr: [Option<Bar>; 0] = [x; 0];
|
||||
|
@ -98,12 +93,6 @@ mod non_constants {
|
|||
let arr: [Option<Bar>; 1] = [x; 1];
|
||||
}
|
||||
|
||||
fn no_impl_copy_value_multiple_elements() {
|
||||
let x = Some(Bar);
|
||||
let arr: [Option<Bar>; 2] = [x; 2];
|
||||
//~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn impl_copy_empty_value_no_elements() {
|
||||
let x: Option<u32> = None;
|
||||
let arr: [Option<u32>; 0] = [x; 0];
|
|
@ -0,0 +1,12 @@
|
|||
// run-pass
|
||||
#![feature(const_in_array_repeat_expressions)]
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
struct Bar;
|
||||
|
||||
fn main() {
|
||||
const FOO: Option<Bar> = None;
|
||||
const ARR: [Option<Bar>; 2] = [FOO; 2];
|
||||
|
||||
assert_eq!(ARR, [None::<Bar>, None::<Bar>]);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// ignore-tidy-linelength
|
||||
#![feature(const_in_array_repeat_expressions)]
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct Foo<T>(T);
|
||||
|
||||
fn main() {
|
||||
[Foo(String::new()); 4];
|
||||
//~^ ERROR the trait bound `Foo<std::string::String>: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
error[E0277]: the trait bound `Foo<std::string::String>: std::marker::Copy` is not satisfied
|
||||
--> $DIR/trait-error.rs:8:5
|
||||
|
|
||||
LL | [Foo(String::new()); 4];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `Foo<std::string::String>`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<Foo<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`.
|
Loading…
Add table
Reference in a new issue