Skip to content

Commit 5f415da

Browse files
Rollup merge of #143300 - Kivooeo:tf25, r=tgross35
`tests/ui`: A New Order [25/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 #133895. r? `@tgross35`
2 parents 069f571 + 066a281 commit 5f415da

25 files changed

+155
-97
lines changed

tests/ui/reexport-test-harness-main.rs renamed to tests/ui/attributes/reexport-test-harness-entry-point.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Check that `#[reexport_test_harness_main]` correctly reexports the test harness entry point
2+
//! and allows it to be called from within the code.
3+
14
//@ run-pass
25
//@ compile-flags:--test
36

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! Check that taking the address of a stack variable with `&`
2+
//! yields a stable and comparable pointer.
3+
//!
4+
//! Regression test for <https://github.com/rust-lang/rust/issues/2040>.
5+
6+
//@ run-pass
7+
8+
pub fn main() {
9+
let foo: isize = 1;
10+
assert_eq!(&foo as *const isize, &foo as *const isize);
11+
}

tests/ui/short-error-format.rs renamed to tests/ui/diagnostic-flags/error-format-short.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Check that compile errors are formatted in the "short" style
2+
//! when `--error-format=short` is used.
3+
14
//@ compile-flags: --error-format=short
25

36
fn foo(_: u32) {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$DIR/error-format-short.rs:9:9: error[E0308]: mismatched types: expected `u32`, found `String`
2+
$DIR/error-format-short.rs:11:7: error[E0599]: no method named `salut` found for type `u32` in the current scope: method not found in `u32`
3+
error: aborting due to 2 previous errors

tests/ui/resource-assign-is-not-copy.rs renamed to tests/ui/drop/drop-once-on-move.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Check that types not implementing `Copy` are moved, not copied, during assignment
2+
//! operations, and their `Drop` implementation is called exactly once when the
3+
//! value goes out of scope.
4+
15
//@ run-pass
26

37
#![allow(non_camel_case_types)]
@@ -15,9 +19,7 @@ impl<'a> Drop for r<'a> {
1519
}
1620

1721
fn r(i: &Cell<isize>) -> r<'_> {
18-
r {
19-
i: i
20-
}
22+
r { i }
2123
}
2224

2325
pub fn main() {
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1+
//! Check that the `Drop` implementation is called when a value goes out of scope.
2+
13
//@ run-pass
24

35
#![allow(non_camel_case_types)]
46
use std::cell::Cell;
57

68
struct shrinky_pointer<'a> {
7-
i: &'a Cell<isize>,
9+
i: &'a Cell<isize>,
810
}
911

1012
impl<'a> Drop for shrinky_pointer<'a> {
1113
fn drop(&mut self) {
12-
println!("Hello!"); self.i.set(self.i.get() - 1);
14+
println!("Hello!");
15+
self.i.set(self.i.get() - 1);
1316
}
1417
}
1518

1619
impl<'a> shrinky_pointer<'a> {
17-
pub fn look_at(&self) -> isize { return self.i.get(); }
20+
pub fn look_at(&self) -> isize {
21+
return self.i.get();
22+
}
1823
}
1924

2025
fn shrinky_pointer(i: &Cell<isize>) -> shrinky_pointer<'_> {
21-
shrinky_pointer {
22-
i: i
23-
}
26+
shrinky_pointer { i }
2427
}
2528

2629
pub fn main() {
2730
let my_total = &Cell::new(10);
28-
{ let pt = shrinky_pointer(my_total); assert_eq!(pt.look_at(), 10); }
31+
{
32+
let pt = shrinky_pointer(my_total);
33+
assert_eq!(pt.look_at(), 10);
34+
}
2935
println!("my_total = {}", my_total.get());
3036
assert_eq!(my_total.get(), 9);
3137
}

tests/ui/seq-args.rs renamed to tests/ui/generics/trait-incorrect-generic-args.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
//! Check for compilation errors when a trait is used with an incorrect number of generic arguments.
2+
13
fn main() {
2-
trait Seq { }
4+
trait Seq {}
35

46
impl<T> Seq<T> for Vec<T> {
57
//~^ ERROR trait takes 0 generic arguments but 1 generic argument

tests/ui/seq-args.stderr renamed to tests/ui/generics/trait-incorrect-generic-args.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
2-
--> $DIR/seq-args.rs:4:13
2+
--> $DIR/trait-incorrect-generic-args.rs:6:13
33
|
44
LL | impl<T> Seq<T> for Vec<T> {
55
| ^^^--- help: remove the unnecessary generics
66
| |
77
| expected 0 generic arguments
88
|
99
note: trait defined here, with 0 generic parameters
10-
--> $DIR/seq-args.rs:2:11
10+
--> $DIR/trait-incorrect-generic-args.rs:4:11
1111
|
12-
LL | trait Seq { }
12+
LL | trait Seq {}
1313
| ^^^
1414

1515
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
16-
--> $DIR/seq-args.rs:9:10
16+
--> $DIR/trait-incorrect-generic-args.rs:11:10
1717
|
1818
LL | impl Seq<bool> for u32 {
1919
| ^^^------ help: remove the unnecessary generics
2020
| |
2121
| expected 0 generic arguments
2222
|
2323
note: trait defined here, with 0 generic parameters
24-
--> $DIR/seq-args.rs:2:11
24+
--> $DIR/trait-incorrect-generic-args.rs:4:11
2525
|
26-
LL | trait Seq { }
26+
LL | trait Seq {}
2727
| ^^^
2828

2929
error: aborting due to 2 previous errors

tests/ui/stdio-is-blocking.rs renamed to tests/ui/io-checks/io-stdout-blocking-writes.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
//! Check that writes to standard output are blocking, avoiding interleaving
2+
//! even with concurrent writes from multiple threads.
3+
14
//@ run-pass
25
//@ needs-subprocess
36

4-
use std::env;
57
use std::io::prelude::*;
68
use std::process::Command;
7-
use std::thread;
9+
use std::{env, thread};
810

911
const THREADS: usize = 20;
1012
const WRITES: usize = 100;
@@ -33,14 +35,16 @@ fn parent() {
3335
}
3436

3537
fn child() {
36-
let threads = (0..THREADS).map(|_| {
37-
thread::spawn(|| {
38-
let buf = [b'a'; WRITE_SIZE];
39-
for _ in 0..WRITES {
40-
write_all(&buf);
41-
}
38+
let threads = (0..THREADS)
39+
.map(|_| {
40+
thread::spawn(|| {
41+
let buf = [b'a'; WRITE_SIZE];
42+
for _ in 0..WRITES {
43+
write_all(&buf);
44+
}
45+
})
4246
})
43-
}).collect::<Vec<_>>();
47+
.collect::<Vec<_>>();
4448

4549
for thread in threads {
4650
thread.join().unwrap();
@@ -63,8 +67,8 @@ fn write_all(buf: &[u8]) {
6367
fn write_all(buf: &[u8]) {
6468
use std::fs::File;
6569
use std::mem;
66-
use std::os::windows::raw::*;
6770
use std::os::windows::prelude::*;
71+
use std::os::windows::raw::*;
6872

6973
const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32;
7074

tests/ui/shadow-bool.rs renamed to tests/ui/shadowed/primitive-type-shadowing.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Check that a primitive type can be shadowed by a user-defined type, and the primitive type
2+
//! can still be referenced using its fully qualified path (e.g., `core::primitive::bool`).
3+
14
//@ check-pass
25

36
mod bar {

0 commit comments

Comments
 (0)