Skip to content

Commit 3d6eb22

Browse files
authored
Rollup merge of #143302 - Kivooeo:tf27, r=tgross35
`tests/ui`: A New Order [27/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 2730beb + 3ad95cc commit 3d6eb22

34 files changed

+219
-173
lines changed

tests/ui/type-param-constraints.rs renamed to tests/ui/auto-traits/auto-traits-type-parameter.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1+
//! Checks how type parameters interact with auto-traits like `Send` and `Sync` with implicit
2+
//! bounds
3+
14
//@ run-pass
25

36
#![allow(non_camel_case_types)]
47
#![allow(dead_code)]
58

6-
fn p_foo<T>(_pinned: T) { }
7-
fn s_foo<T>(_shared: T) { }
8-
fn u_foo<T:Send>(_unique: T) { }
9+
fn p_foo<T>(_pinned: T) {}
10+
fn s_foo<T>(_shared: T) {}
11+
fn u_foo<T: Send>(_unique: T) {}
912

1013
struct r {
11-
i: isize,
14+
i: isize,
1215
}
1316

1417
impl Drop for r {
1518
fn drop(&mut self) {}
1619
}
1720

18-
fn r(i:isize) -> r {
19-
r {
20-
i: i
21-
}
21+
fn r(i: isize) -> r {
22+
r { i }
2223
}
2324

2425
pub fn main() {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! This checks that compiler correctly evaluate constant array lengths within trait `impl` headers.
2+
//!
3+
//! Regression test for <https://github.com/rust-lang/rust/issues/49208>.
4+
5+
trait Foo {
6+
fn foo();
7+
}
8+
9+
impl Foo for [(); 1] {
10+
fn foo() {}
11+
}
12+
13+
fn main() {
14+
<[(); 0] as Foo>::foo() //~ ERROR E0277
15+
}

tests/ui/unevaluated_fixed_size_array_len.stderr renamed to tests/ui/consts/const-eval-array-len-in-impl.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `[(); 0]: Foo` is not satisfied
2-
--> $DIR/unevaluated_fixed_size_array_len.rs:12:6
2+
--> $DIR/const-eval-array-len-in-impl.rs:14:6
33
|
44
LL | <[(); 0] as Foo>::foo()
55
| ^^^^^^^ the trait `Foo` is not implemented for `[(); 0]`

tests/ui/typestate-multi-decl.rs renamed to tests/ui/destructuring-assignment/let-binding-tuple-destructuring.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Checks basic multiple variable declaration using tuple destructuring in a `let` binding.
2+
13
//@ run-pass
24

35
pub fn main() {

tests/ui/type-id-higher-rank-2.rs renamed to tests/ui/lifetimes/any-lifetime-escape-higher-rank.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
//! Checks that `std::any::Any` cannot be used to circumvent lifetime rules
2+
//! with higher-rank types.
3+
14
//@ run-pass
2-
// Test that we can't ignore lifetimes by going through Any.
35

46
use std::any::Any;
57

68
struct Foo<'a>(&'a str);
79

8-
fn good(s: &String) -> Foo<'_> { Foo(s) }
10+
fn good(s: &String) -> Foo<'_> {
11+
Foo(s)
12+
}
913

1014
fn bad1(s: String) -> Option<&'static str> {
1115
let a: Box<dyn Any> = Box::new(good as fn(&String) -> Foo);
@@ -17,7 +21,9 @@ trait AsStr<'a, 'b> {
1721
}
1822

1923
impl<'a> AsStr<'a, 'a> for String {
20-
fn get(&'a self) -> &'a str { self }
24+
fn get(&'a self) -> &'a str {
25+
self
26+
}
2127
}
2228

2329
fn bad2(s: String) -> Option<&'static str> {

tests/ui/type_length_limit.rs renamed to tests/ui/limits/type-length-limit-enforcement.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
//@ build-fail
1+
//~ ERROR reached the type-length limit
2+
3+
//! Checks the enforcement of the type-length limit
4+
//! and its configurability via `#![type_length_limit]`.
5+
26
//@ compile-flags: -Copt-level=0 -Zenforce-type-length-limit
3-
//~^^ ERROR reached the type-length limit
47

5-
// Test that the type length limit can be changed.
6-
// The exact type depends on optimizations, so disable them.
8+
//@ build-fail
79

810
#![allow(dead_code)]
9-
#![type_length_limit="8"]
11+
#![type_length_limit = "8"]
1012

1113
macro_rules! link {
1214
($id:ident, $t:ty) => {
1315
pub type $id = ($t, $t, $t);
14-
}
16+
};
1517
}
1618

1719
link! { A1, B1 }
@@ -26,7 +28,7 @@ link! { D, E }
2628
link! { E, F }
2729
link! { F, G<Option<i32>, Option<i32>> }
2830

29-
pub struct G<T, K>(std::marker::PhantomData::<(T, K)>);
31+
pub struct G<T, K>(std::marker::PhantomData<(T, K)>);
3032

3133
fn main() {
3234
drop::<Option<A>>(None);

tests/ui/type_length_limit.stderr renamed to tests/ui/limits/type-length-limit-enforcement.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: reached the type-length limit while instantiating `std::mem::drop::<Option<((((..., ..., ...), ..., ...), ..., ...), ..., ...)>>`
2-
--> $DIR/type_length_limit.rs:32:5
2+
--> $DIR/type-length-limit-enforcement.rs:34:5
33
|
44
LL | drop::<Option<A>>(None);
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: consider adding a `#![type_length_limit="4010"]` attribute to your crate
8-
= note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit.long-type.txt'
8+
= note: the full type name has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type.txt'
99

1010
error: reached the type-length limit while instantiating `<{closure@rt::lang_start<()>::{closure#0}} as FnMut<()>>::call_mut`
1111
|
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//! Verifies that the reserved underscore `_` cannot be used as an `ident` fragment specifier
2+
//! within a macro pattern, as it leads to a compilation error.
3+
4+
macro_rules! identity {
5+
($i: ident) => {
6+
$i
7+
};
8+
}
9+
10+
fn main() {
11+
let identity!(_) = 10; //~ ERROR no rules expected reserved identifier `_`
12+
}

tests/ui/underscore-ident-matcher.stderr renamed to tests/ui/macros/macro-fragment-ident-underscore-error.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: no rules expected reserved identifier `_`
2-
--> $DIR/underscore-ident-matcher.rs:8:19
2+
--> $DIR/macro-fragment-ident-underscore-error.rs:11:19
33
|
44
LL | macro_rules! identity {
55
| --------------------- when calling this macro
@@ -8,9 +8,9 @@ LL | let identity!(_) = 10;
88
| ^ no rules expected this token in macro call
99
|
1010
note: while trying to match meta-variable `$i:ident`
11-
--> $DIR/underscore-ident-matcher.rs:2:6
11+
--> $DIR/macro-fragment-ident-underscore-error.rs:5:6
1212
|
13-
LL | ($i: ident) => (
13+
LL | ($i: ident) => {
1414
| ^^^^^^^^^
1515

1616
error: aborting due to 1 previous error
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ run-pass
2+
3+
struct A {
4+
a: isize,
5+
}
6+
7+
fn a(a: A) -> isize {
8+
return a.a;
9+
}
10+
11+
pub fn main() {
12+
let x: A = A { a: 1 };
13+
assert_eq!(a(x), 1);
14+
}

0 commit comments

Comments
 (0)