Skip to content

tests/ui: A New Order [22/N] #143297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
9 changes: 0 additions & 9 deletions tests/ui/occurs-check-2.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui/occurs-check-3.rs

This file was deleted.

5 changes: 0 additions & 5 deletions tests/ui/occurs-check.rs

This file was deleted.

17 changes: 0 additions & 17 deletions tests/ui/opeq.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you delete something, could you put the reason in the commit message? I'm sure it's fine but describing the reason for a change always takes the guesswork out :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a very basic test that we're testing miltiple times in other places, very simple, if needed I can found same tests in other tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it makes sense; just put that in the first commit message pls :) (to help the next person who looks at the log and has this question)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a description to this moved commit, not sure if this was what you meant, but this is how I understood this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's exactly it :) it's always good practice for a commit message to explain why a change is done

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Test that `Copy` cannot be implemented if any field doesn't implement `Copy`.

struct CantCopyThis;

struct IWantToCopyThis {
Expand Down
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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`
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/type-inference/direct-self-reference-occurs-check.rs
Original file line number Diff line number Diff line change
@@ -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 `_`
}
Original file line number Diff line number Diff line change
@@ -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);
| ^
Expand Down
16 changes: 16 additions & 0 deletions tests/ui/type-inference/enum-self-reference-occurs-check.rs
Original file line number Diff line number Diff line change
@@ -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>(_) => {}
}
}
Original file line number Diff line number Diff line change
@@ -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);
| ^
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/type-inference/infinite-type-occurs-check.rs
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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;
| ^
Expand Down
Loading