Rollup merge of #143297 - Kivooeo:tf22, r=tgross35
`tests/ui`: A New Order [22/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@tgross35`
This commit is contained in:
commit
fde4de4d2d
16 changed files with 57 additions and 60 deletions
|
|
@ -1,9 +1,8 @@
|
|||
//! Test compound assignment operators with reference right-hand side.
|
||||
|
||||
//@ run-pass
|
||||
|
||||
fn main() {
|
||||
// test compound assignment operators with ref as right-hand side,
|
||||
// for each operator, with various types as operands.
|
||||
|
||||
// test AddAssign
|
||||
{
|
||||
let mut x = 3i8;
|
||||
|
|
@ -1,16 +1,15 @@
|
|||
// Testing guarantees provided by once functions.
|
||||
// This program would segfault if it were legal.
|
||||
//! Test that `FnOnce` closures cannot be called twice.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
fn foo<F:FnOnce()>(blk: F) {
|
||||
fn foo<F: FnOnce()>(blk: F) {
|
||||
blk();
|
||||
blk(); //~ ERROR use of moved value
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Arc::new(true);
|
||||
foo(move|| {
|
||||
foo(move || {
|
||||
assert!(*x);
|
||||
drop(x);
|
||||
});
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
error[E0382]: use of moved value: `blk`
|
||||
--> $DIR/once-cant-call-twice-on-heap.rs:8:5
|
||||
--> $DIR/fnonce-call-twice-error.rs:7:5
|
||||
|
|
||||
LL | fn foo<F:FnOnce()>(blk: F) {
|
||||
| --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait
|
||||
LL | fn foo<F: FnOnce()>(blk: F) {
|
||||
| --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait
|
||||
LL | blk();
|
||||
| ----- `blk` moved due to this call
|
||||
LL | blk();
|
||||
| ^^^ value used here after move
|
||||
|
|
||||
note: `FnOnce` closures can only be called once
|
||||
--> $DIR/once-cant-call-twice-on-heap.rs:6:10
|
||||
--> $DIR/fnonce-call-twice-error.rs:5:11
|
||||
|
|
||||
LL | fn foo<F:FnOnce()>(blk: F) {
|
||||
| ^^^^^^^^ `F` is made to be an `FnOnce` closure here
|
||||
LL | fn foo<F: FnOnce()>(blk: F) {
|
||||
| ^^^^^^^^ `F` is made to be an `FnOnce` closure here
|
||||
LL | blk();
|
||||
| ----- this value implements `FnOnce`, which causes it to be moved when called
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
fn main() {
|
||||
|
||||
let f;
|
||||
let g;
|
||||
|
||||
g = f;
|
||||
//~^ ERROR overflow assigning `Box<_>` to `_`
|
||||
f = Box::new(g);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
// From Issue #778
|
||||
|
||||
enum Clam<T> { A(T) }
|
||||
fn main() {
|
||||
let c;
|
||||
c = Clam::A(c);
|
||||
//~^ ERROR overflow assigning `Clam<_>` to `_`
|
||||
match c {
|
||||
Clam::A::<isize>(_) => { }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
fn main() {
|
||||
let f;
|
||||
f = Box::new(f);
|
||||
//~^ ERROR overflow assigning `Box<_>` to `_`
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
pub fn main() {
|
||||
let mut x: isize = 1;
|
||||
x *= 2;
|
||||
println!("{}", x);
|
||||
assert_eq!(x, 2);
|
||||
x += 3;
|
||||
println!("{}", x);
|
||||
assert_eq!(x, 5);
|
||||
x *= x;
|
||||
println!("{}", x);
|
||||
assert_eq!(x, 25);
|
||||
x /= 5;
|
||||
println!("{}", x);
|
||||
assert_eq!(x, 5);
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
//! Test that out-of-memory conditions trigger catchable panics with `-Z oom=panic`.
|
||||
|
||||
//@ compile-flags: -Z oom=panic
|
||||
//@ run-pass
|
||||
//@ no-prefer-dynamic
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
//! Test that `Copy` cannot be implemented if any field doesn't implement `Copy`.
|
||||
|
||||
struct CantCopyThis;
|
||||
|
||||
struct IWantToCopyThis {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/opt-in-copy.rs:7:15
|
||||
--> $DIR/copy-requires-all-fields-copy.rs:9:15
|
||||
|
|
||||
LL | but_i_cant: CantCopyThis,
|
||||
| ------------------------ this field does not implement `Copy`
|
||||
|
|
@ -8,7 +8,7 @@ LL | impl Copy for IWantToCopyThis {}
|
|||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0204]: the trait `Copy` cannot be implemented for this type
|
||||
--> $DIR/opt-in-copy.rs:19:15
|
||||
--> $DIR/copy-requires-all-fields-copy.rs:21:15
|
||||
|
|
||||
LL | ButICant(CantCopyThisEither),
|
||||
| ------------------ this field does not implement `Copy`
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
//! Test that occurs check prevents direct self-reference in variable assignment.
|
||||
//!
|
||||
//! Regression test for <https://github.com/rust-lang/rust/issues/768>.
|
||||
|
||||
fn main() {
|
||||
let f;
|
||||
f = Box::new(f);
|
||||
//~^ ERROR overflow assigning `Box<_>` to `_`
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0275]: overflow assigning `Box<_>` to `_`
|
||||
--> $DIR/occurs-check.rs:3:18
|
||||
--> $DIR/direct-self-reference-occurs-check.rs:7:18
|
||||
|
|
||||
LL | f = Box::new(f);
|
||||
| ^
|
||||
16
tests/ui/type-inference/enum-self-reference-occurs-check.rs
Normal file
16
tests/ui/type-inference/enum-self-reference-occurs-check.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//! Test that occurs check prevents infinite types with enum self-references.
|
||||
//!
|
||||
//! Regression test for <https://github.com/rust-lang/rust/issues/778>.
|
||||
|
||||
enum Clam<T> {
|
||||
A(T),
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let c;
|
||||
c = Clam::A(c);
|
||||
//~^ ERROR overflow assigning `Clam<_>` to `_`
|
||||
match c {
|
||||
Clam::A::<isize>(_) => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0275]: overflow assigning `Clam<_>` to `_`
|
||||
--> $DIR/occurs-check-3.rs:6:17
|
||||
--> $DIR/enum-self-reference-occurs-check.rs:11:17
|
||||
|
|
||||
LL | c = Clam::A(c);
|
||||
| ^
|
||||
12
tests/ui/type-inference/infinite-type-occurs-check.rs
Normal file
12
tests/ui/type-inference/infinite-type-occurs-check.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//! Test that occurs check prevents infinite types during type inference.
|
||||
//!
|
||||
//! Regression test for <https://github.com/rust-lang/rust/issues/768>.
|
||||
|
||||
fn main() {
|
||||
let f;
|
||||
let g;
|
||||
|
||||
g = f;
|
||||
//~^ ERROR overflow assigning `Box<_>` to `_`
|
||||
f = Box::new(g);
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0275]: overflow assigning `Box<_>` to `_`
|
||||
--> $DIR/occurs-check-2.rs:6:9
|
||||
--> $DIR/infinite-type-occurs-check.rs:9:9
|
||||
|
|
||||
LL | g = f;
|
||||
| ^
|
||||
Loading…
Add table
Add a link
Reference in a new issue