Skip to content

Commit 069f571

Browse files
Rollup merge of #143299 - Kivooeo:tf24, r=tgross35
`tests/ui`: A New Order [24/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 fde4de4 + b28806d commit 069f571

29 files changed

+264
-204
lines changed

tests/ui/realloc-16687.rs renamed to tests/ui/allocator/alloc-shrink-oob-read.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
//! Sanity check for out-of-bounds read caused by copying the entire original buffer on shrink.
2+
//!
3+
//! Regression test for: <https://github.com/rust-lang/rust/issues/16687>
4+
15
//@ run-pass
2-
// alloc::heap::reallocate test.
3-
//
4-
// Ideally this would be revised to use no_std, but for now it serves
5-
// well enough to reproduce (and illustrate) the bug from #16687.
66

77
#![feature(allocator_api)]
88
#![feature(slice_ptr_get)]
99

10-
use std::alloc::{handle_alloc_error, Allocator, Global, Layout};
10+
use std::alloc::{Allocator, Global, Layout, handle_alloc_error};
1111
use std::ptr::{self, NonNull};
1212

1313
fn main() {

tests/ui/phantom-auto-trait.rs renamed to tests/ui/auto-traits/auto-trait-phantom-data-bounds.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of
2-
// checking the `PhantomData<T>` type itself (which almost always implements an auto trait).
1+
//! Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of
2+
//! checking the `PhantomData<T>` type itself (which almost always implements an auto trait).
33
44
#![feature(auto_traits)]
55

6-
use std::marker::{PhantomData};
6+
use std::marker::PhantomData;
77

88
unsafe auto trait Zen {}
99

tests/ui/phantom-auto-trait.stderr renamed to tests/ui/auto-traits/auto-trait-phantom-data-bounds.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
error[E0277]: `T` cannot be shared between threads safely
2-
--> $DIR/phantom-auto-trait.rs:21:12
2+
--> $DIR/auto-trait-phantom-data-bounds.rs:21:12
33
|
44
LL | is_zen(x)
55
| ------ ^ `T` cannot be shared between threads safely
66
| |
77
| required by a bound introduced by this call
88
|
99
note: required for `&T` to implement `Zen`
10-
--> $DIR/phantom-auto-trait.rs:10:24
10+
--> $DIR/auto-trait-phantom-data-bounds.rs:10:24
1111
|
1212
LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {}
1313
| ^^^ ^^^^^ ---- unsatisfied trait bound introduced here
1414
note: required because it appears within the type `PhantomData<&T>`
1515
--> $SRC_DIR/core/src/marker.rs:LL:COL
1616
note: required because it appears within the type `Guard<'_, T>`
17-
--> $DIR/phantom-auto-trait.rs:12:8
17+
--> $DIR/auto-trait-phantom-data-bounds.rs:12:8
1818
|
1919
LL | struct Guard<'a, T: 'a> {
2020
| ^^^^^
2121
note: required by a bound in `is_zen`
22-
--> $DIR/phantom-auto-trait.rs:18:14
22+
--> $DIR/auto-trait-phantom-data-bounds.rs:18:14
2323
|
2424
LL | fn is_zen<T: Zen>(_: T) {}
2525
| ^^^ required by this bound in `is_zen`
@@ -29,32 +29,32 @@ LL | fn not_sync<T: std::marker::Sync>(x: Guard<T>) {
2929
| +++++++++++++++++++
3030

3131
error[E0277]: `T` cannot be shared between threads safely
32-
--> $DIR/phantom-auto-trait.rs:26:12
32+
--> $DIR/auto-trait-phantom-data-bounds.rs:26:12
3333
|
3434
LL | is_zen(x)
3535
| ------ ^ `T` cannot be shared between threads safely
3636
| |
3737
| required by a bound introduced by this call
3838
|
3939
note: required for `&T` to implement `Zen`
40-
--> $DIR/phantom-auto-trait.rs:10:24
40+
--> $DIR/auto-trait-phantom-data-bounds.rs:10:24
4141
|
4242
LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {}
4343
| ^^^ ^^^^^ ---- unsatisfied trait bound introduced here
4444
note: required because it appears within the type `PhantomData<&T>`
4545
--> $SRC_DIR/core/src/marker.rs:LL:COL
4646
note: required because it appears within the type `Guard<'_, T>`
47-
--> $DIR/phantom-auto-trait.rs:12:8
47+
--> $DIR/auto-trait-phantom-data-bounds.rs:12:8
4848
|
4949
LL | struct Guard<'a, T: 'a> {
5050
| ^^^^^
5151
note: required because it appears within the type `Nested<Guard<'_, T>>`
52-
--> $DIR/phantom-auto-trait.rs:16:8
52+
--> $DIR/auto-trait-phantom-data-bounds.rs:16:8
5353
|
5454
LL | struct Nested<T>(T);
5555
| ^^^^^^
5656
note: required by a bound in `is_zen`
57-
--> $DIR/phantom-auto-trait.rs:18:14
57+
--> $DIR/auto-trait-phantom-data-bounds.rs:18:14
5858
|
5959
LL | fn is_zen<T: Zen>(_: T) {}
6060
| ^^^ required by this bound in `is_zen`
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! Test evaluation order in binary operations with primitive types.
2+
3+
//@ run-pass
4+
5+
fn main() {
6+
let x = Box::new(0);
7+
assert_eq!(
8+
0,
9+
*x + {
10+
drop(x);
11+
let _ = Box::new(main);
12+
0
13+
}
14+
);
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! Tests basic pointer coercions
2+
3+
//@ run-pass
4+
5+
pub fn main() {
6+
// &mut -> &
7+
let x: &mut isize = &mut 42;
8+
let _x: &isize = x;
9+
let _x: &isize = &mut 42;
10+
11+
// & -> *const
12+
let x: &isize = &42;
13+
let _x: *const isize = x;
14+
let _x: *const isize = &42;
15+
16+
// &mut -> *const
17+
let x: &mut isize = &mut 42;
18+
let _x: *const isize = x;
19+
let _x: *const isize = &mut 42;
20+
21+
// *mut -> *const
22+
let _x: *mut isize = &mut 42;
23+
let _x: *const isize = x;
24+
}

tests/ui/ptr-coercion.rs renamed to tests/ui/coercion/ptr-mutability-errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Test coercions between pointers which don't do anything fancy like unsizing.
2-
// These are testing that we don't lose mutability when converting to raw pointers.
1+
//! Tests that pointer coercions preserving mutability are enforced:
32
43
//@ dont-require-annotations: NOTE
54

tests/ui/ptr-coercion.stderr renamed to tests/ui/coercion/ptr-mutability-errors.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/ptr-coercion.rs:9:25
2+
--> $DIR/ptr-mutability-errors.rs:8:25
33
|
44
LL | let x: *mut isize = x;
55
| ---------- ^ types differ in mutability
@@ -10,7 +10,7 @@ LL | let x: *mut isize = x;
1010
found raw pointer `*const isize`
1111

1212
error[E0308]: mismatched types
13-
--> $DIR/ptr-coercion.rs:15:25
13+
--> $DIR/ptr-mutability-errors.rs:14:25
1414
|
1515
LL | let x: *mut isize = &42;
1616
| ---------- ^^^ types differ in mutability
@@ -21,7 +21,7 @@ LL | let x: *mut isize = &42;
2121
found reference `&isize`
2222

2323
error[E0308]: mismatched types
24-
--> $DIR/ptr-coercion.rs:21:25
24+
--> $DIR/ptr-mutability-errors.rs:20:25
2525
|
2626
LL | let x: *mut isize = x;
2727
| ---------- ^ types differ in mutability

tests/ui/print-stdout-eprint-stderr.rs renamed to tests/ui/io-checks/stdout-stderr-separation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Test that print!/println! output to stdout and eprint!/eprintln!
2+
//! output to stderr correctly.
3+
14
//@ run-pass
25
//@ needs-subprocess
36

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//! Test closure parameter type inference and type mismatch errors.
2+
//!
3+
//! Related to <https://github.com/rust-lang/rust/issues/2093>.
4+
5+
//@ dont-require-annotations: NOTE
6+
7+
fn let_in<T, F>(x: T, f: F)
8+
where
9+
F: FnOnce(T),
10+
{
11+
}
12+
13+
fn main() {
14+
let_in(3u32, |i| {
15+
assert!(i == 3i32);
16+
//~^ ERROR mismatched types
17+
//~| NOTE expected `u32`, found `i32`
18+
});
19+
20+
let_in(3i32, |i| {
21+
assert!(i == 3u32);
22+
//~^ ERROR mismatched types
23+
//~| NOTE expected `i32`, found `u32`
24+
});
25+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/closure-parameter-type-inference-mismatch.rs:15:22
3+
|
4+
LL | assert!(i == 3i32);
5+
| - ^^^^ expected `u32`, found `i32`
6+
| |
7+
| expected because this is `u32`
8+
|
9+
help: change the type of the numeric literal from `i32` to `u32`
10+
|
11+
LL - assert!(i == 3i32);
12+
LL + assert!(i == 3u32);
13+
|
14+
15+
error[E0308]: mismatched types
16+
--> $DIR/closure-parameter-type-inference-mismatch.rs:21:22
17+
|
18+
LL | assert!(i == 3u32);
19+
| - ^^^^ expected `i32`, found `u32`
20+
| |
21+
| expected because this is `i32`
22+
|
23+
help: change the type of the numeric literal from `u32` to `i32`
24+
|
25+
LL - assert!(i == 3u32);
26+
LL + assert!(i == 3i32);
27+
|
28+
29+
error: aborting due to 2 previous errors
30+
31+
For more information about this error, try `rustc --explain E0308`.

tests/ui/point-to-type-err-cause-on-impl-trait-return-2.rs renamed to tests/ui/mismatched_types/type-error-diagnostic-in-complex-return.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
fn unrelated() -> Result<(), std::string::ParseError> { // #57664
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/57664>.
2+
//! Checks that compiler doesn't get confused by `?` operator and complex
3+
//! return types when reporting type mismatches.
4+
5+
fn unrelated() -> Result<(), std::string::ParseError> {
26
let x = 0;
37

48
match x {

tests/ui/point-to-type-err-cause-on-impl-trait-return-2.stderr renamed to tests/ui/mismatched_types/type-error-diagnostic-in-complex-return.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/point-to-type-err-cause-on-impl-trait-return-2.rs:9:41
2+
--> $DIR/type-error-diagnostic-in-complex-return.rs:13:41
33
|
44
LL | let value: &bool = unsafe { &42 };
55
| ^^^ expected `&bool`, found `&{integer}`
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//! Tests correct parsing of doc comments on generic parameters in traits.
2+
//! Checks that compiler doesn't panic when processing this.
3+
4+
//@ check-pass
5+
6+
#![crate_type = "lib"]
7+
8+
pub trait Layer<
9+
/// Documentation for generic parameter.
10+
Input,
11+
>
12+
{
13+
}
998 Bytes
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! Tests how we behave when the user attempts to mutate an immutable
2+
//! binding that was introduced by either `ref` or `ref mut`
3+
//! patterns.
4+
//!
5+
//! Such bindings cannot be made mutable via the mere addition of the
6+
//! `mut` keyword, and thus we want to check that the compiler does not
7+
//! suggest doing so.
8+
9+
fn main() {
10+
let (mut one_two, mut three_four) = ((1, 2), (3, 4));
11+
12+
// Bind via pattern:
13+
// - `a` as immutable reference (`ref`)
14+
// - `b` as mutable reference (`ref mut`)
15+
let &mut (ref a, ref mut b) = &mut one_two;
16+
17+
// Attempt to reassign immutable `ref`-bound variable
18+
a = &three_four.0;
19+
//~^ ERROR cannot assign twice to immutable variable `a`
20+
21+
// Attempt to reassign mutable `ref mut`-bound variable
22+
b = &mut three_four.1;
23+
//~^ ERROR cannot assign twice to immutable variable `b`
24+
}

tests/ui/reassign-ref-mut.stderr renamed to tests/ui/pattern/move-ref-patterns/pattern-ref-bindings-reassignment.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
error[E0384]: cannot assign twice to immutable variable `a`
2-
--> $DIR/reassign-ref-mut.rs:12:5
2+
--> $DIR/pattern-ref-bindings-reassignment.rs:18:5
33
|
44
LL | let &mut (ref a, ref mut b) = &mut one_two;
55
| ----- first assignment to `a`
6+
...
67
LL | a = &three_four.0;
78
| ^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable
89

910
error[E0384]: cannot assign twice to immutable variable `b`
10-
--> $DIR/reassign-ref-mut.rs:14:5
11+
--> $DIR/pattern-ref-bindings-reassignment.rs:22:5
1112
|
1213
LL | let &mut (ref a, ref mut b) = &mut one_two;
1314
| --------- first assignment to `b`

tests/ui/pptypedef.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/pptypedef.stderr

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/ui/primitive-binop-lhs-mut.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ui/print-calling-conventions.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//! Test that `--print calling-conventions` outputs all supported calling conventions.
2+
3+
//@ compile-flags: --print calling-conventions
4+
//@ build-pass

0 commit comments

Comments
 (0)