Skip to content

Commit 1d7329f

Browse files
authored
Unrolled build for rust-lang#133900
Rollup merge of rust-lang#133900 - jieyouxu:ui-cleanup-1, r=fmease Advent of `tests/ui` (misc cleanups and improvements) [1/N] Part of rust-lang#133895. Misc improvements to some ui tests immediately under `tests/ui/`. Best reviewed commit-by-commit. Thanks `@clubby789` for PR title suggestion 😸. r? compiler
2 parents 327c7ee + 56efa0a commit 1d7329f

11 files changed

+137
-64
lines changed

tests/ui/alias-uninit-value.rs

-19
This file was deleted.

tests/ui/allow-non-lint-warnings.rs

-8
This file was deleted.

tests/ui/artificial-block.rs

-5
This file was deleted.

tests/ui/as-precedence.rs

-10
This file was deleted.
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//! Regression test for issue #374, where previously rustc performed conditional jumps or moves that
2+
//! incorrectly depended on uninitialized values.
3+
//!
4+
//! Issue: <https://github.com/rust-lang/rust/issues/374>.
5+
6+
//@ run-pass
7+
8+
#![allow(dead_code)]
9+
10+
enum TyS {
11+
Nil,
12+
}
13+
14+
struct RawT {
15+
struct_: TyS,
16+
cname: Option<String>,
17+
hash: usize,
18+
}
19+
20+
fn mk_raw_ty(st: TyS, cname: Option<String>) -> RawT {
21+
return RawT { struct_: st, cname: cname, hash: 0 };
22+
}
23+
24+
pub fn main() {
25+
mk_raw_ty(TyS::Nil, None::<String>);
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ignore-tidy-linelength
2+
//! Check that `-A warnings` cli flag applies to non-lint warnings as well.
3+
//!
4+
//! This test tries to exercise that by checking that the "relaxing a default bound only does
5+
//! something for `?Sized`; all other traits are not bound by default" non-lint warning (normally
6+
//! warn-by-default) is suppressed if the `-A warnings` cli flag is passed.
7+
//!
8+
//! Take special note that `warnings` is a special pseudo lint group in relationship to non-lint
9+
//! warnings, which is somewhat special. This test does not exercise other `-A <other_lint_group>`
10+
//! that check that they are working in the same way, only `warnings` specifically.
11+
//!
12+
//! # Relevant context
13+
//!
14+
//! - Original impl PR: <https://github.com/rust-lang/rust/pull/21248>.
15+
//! - RFC 507 "Release channels":
16+
//! <https://github.com/rust-lang/rfcs/blob/c017755b9bfa0421570d92ba38082302e0f3ad4f/text/0507-release-channels.md>.
17+
#![crate_type = "lib"]
18+
19+
//@ revisions: without_flag with_flag
20+
21+
//@[with_flag] compile-flags: -Awarnings
22+
23+
//@ check-pass
24+
25+
pub trait Trait {}
26+
pub fn f<T: ?Trait>() {}
27+
//[without_flag]~^ WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
2+
--> $DIR/allow-non-lint-warnings.rs:26:13
3+
|
4+
LL | pub fn f<T: ?Trait>() {}
5+
| ^^^^^^
6+
7+
warning: 1 warning emitted
8+

tests/ui/anonymous-higher-ranked-lifetime.rs tests/ui/higher-ranked/anonymous-higher-ranked-lifetime.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Diagnostics test to check that higher-ranked lifetimes are properly named when being pretty
2+
//! printed in diagnostics.
3+
//!
4+
//! Issue: <https://github.com/rust-lang/rust/issues/44887>
5+
//! PR: <https://github.com/rust-lang/rust/pull/44888>
6+
17
fn main() {
28
f1(|_: (), _: ()| {}); //~ ERROR type mismatch
39
f2(|_: (), _: ()| {}); //~ ERROR type mismatch

tests/ui/anonymous-higher-ranked-lifetime.stderr tests/ui/higher-ranked/anonymous-higher-ranked-lifetime.stderr

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0631]: type mismatch in closure arguments
2-
--> $DIR/anonymous-higher-ranked-lifetime.rs:2:5
2+
--> $DIR/anonymous-higher-ranked-lifetime.rs:8:5
33
|
44
LL | f1(|_: (), _: ()| {});
55
| ^^^--------------^^^^
@@ -10,7 +10,7 @@ LL | f1(|_: (), _: ()| {});
1010
= note: expected closure signature `for<'a, 'b> fn(&'a (), &'b ()) -> _`
1111
found closure signature `fn((), ()) -> _`
1212
note: required by a bound in `f1`
13-
--> $DIR/anonymous-higher-ranked-lifetime.rs:16:25
13+
--> $DIR/anonymous-higher-ranked-lifetime.rs:22:25
1414
|
1515
LL | fn f1<F>(_: F) where F: Fn(&(), &()) {}
1616
| ^^^^^^^^^^^^ required by this bound in `f1`
@@ -20,7 +20,7 @@ LL | f1(|_: &(), _: &()| {});
2020
| + +
2121

2222
error[E0631]: type mismatch in closure arguments
23-
--> $DIR/anonymous-higher-ranked-lifetime.rs:3:5
23+
--> $DIR/anonymous-higher-ranked-lifetime.rs:9:5
2424
|
2525
LL | f2(|_: (), _: ()| {});
2626
| ^^^--------------^^^^
@@ -31,7 +31,7 @@ LL | f2(|_: (), _: ()| {});
3131
= note: expected closure signature `for<'a, 'b> fn(&'a (), &'b ()) -> _`
3232
found closure signature `fn((), ()) -> _`
3333
note: required by a bound in `f2`
34-
--> $DIR/anonymous-higher-ranked-lifetime.rs:17:25
34+
--> $DIR/anonymous-higher-ranked-lifetime.rs:23:25
3535
|
3636
LL | fn f2<F>(_: F) where F: for<'a> Fn(&'a (), &()) {}
3737
| ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f2`
@@ -41,7 +41,7 @@ LL | f2(|_: &(), _: &()| {});
4141
| + +
4242

4343
error[E0631]: type mismatch in closure arguments
44-
--> $DIR/anonymous-higher-ranked-lifetime.rs:4:5
44+
--> $DIR/anonymous-higher-ranked-lifetime.rs:10:5
4545
|
4646
LL | f3(|_: (), _: ()| {});
4747
| ^^^--------------^^^^
@@ -52,7 +52,7 @@ LL | f3(|_: (), _: ()| {});
5252
= note: expected closure signature `for<'a> fn(&(), &'a ()) -> _`
5353
found closure signature `fn((), ()) -> _`
5454
note: required by a bound in `f3`
55-
--> $DIR/anonymous-higher-ranked-lifetime.rs:18:29
55+
--> $DIR/anonymous-higher-ranked-lifetime.rs:24:29
5656
|
5757
LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {}
5858
| ^^^^^^^^^^^^^^^ required by this bound in `f3`
@@ -62,7 +62,7 @@ LL | f3(|_: &(), _: &()| {});
6262
| + +
6363

6464
error[E0631]: type mismatch in closure arguments
65-
--> $DIR/anonymous-higher-ranked-lifetime.rs:5:5
65+
--> $DIR/anonymous-higher-ranked-lifetime.rs:11:5
6666
|
6767
LL | f4(|_: (), _: ()| {});
6868
| ^^^--------------^^^^
@@ -73,7 +73,7 @@ LL | f4(|_: (), _: ()| {});
7373
= note: expected closure signature `for<'a, 'r> fn(&'a (), &'r ()) -> _`
7474
found closure signature `fn((), ()) -> _`
7575
note: required by a bound in `f4`
76-
--> $DIR/anonymous-higher-ranked-lifetime.rs:19:25
76+
--> $DIR/anonymous-higher-ranked-lifetime.rs:25:25
7777
|
7878
LL | fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {}
7979
| ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f4`
@@ -83,7 +83,7 @@ LL | f4(|_: &(), _: &()| {});
8383
| + +
8484

8585
error[E0631]: type mismatch in closure arguments
86-
--> $DIR/anonymous-higher-ranked-lifetime.rs:6:5
86+
--> $DIR/anonymous-higher-ranked-lifetime.rs:12:5
8787
|
8888
LL | f5(|_: (), _: ()| {});
8989
| ^^^--------------^^^^
@@ -94,7 +94,7 @@ LL | f5(|_: (), _: ()| {});
9494
= note: expected closure signature `for<'r> fn(&'r (), &'r ()) -> _`
9595
found closure signature `fn((), ()) -> _`
9696
note: required by a bound in `f5`
97-
--> $DIR/anonymous-higher-ranked-lifetime.rs:20:25
97+
--> $DIR/anonymous-higher-ranked-lifetime.rs:26:25
9898
|
9999
LL | fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {}
100100
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f5`
@@ -104,7 +104,7 @@ LL | f5(|_: &(), _: &()| {});
104104
| + +
105105

106106
error[E0631]: type mismatch in closure arguments
107-
--> $DIR/anonymous-higher-ranked-lifetime.rs:7:5
107+
--> $DIR/anonymous-higher-ranked-lifetime.rs:13:5
108108
|
109109
LL | g1(|_: (), _: ()| {});
110110
| ^^^--------------^^^^
@@ -115,7 +115,7 @@ LL | g1(|_: (), _: ()| {});
115115
= note: expected closure signature `for<'a> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>) -> _`
116116
found closure signature `fn((), ()) -> _`
117117
note: required by a bound in `g1`
118-
--> $DIR/anonymous-higher-ranked-lifetime.rs:23:25
118+
--> $DIR/anonymous-higher-ranked-lifetime.rs:29:25
119119
|
120120
LL | fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {}
121121
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g1`
@@ -125,7 +125,7 @@ LL | g1(|_: &(), _: ()| {});
125125
| +
126126

127127
error[E0631]: type mismatch in closure arguments
128-
--> $DIR/anonymous-higher-ranked-lifetime.rs:8:5
128+
--> $DIR/anonymous-higher-ranked-lifetime.rs:14:5
129129
|
130130
LL | g2(|_: (), _: ()| {});
131131
| ^^^--------------^^^^
@@ -136,7 +136,7 @@ LL | g2(|_: (), _: ()| {});
136136
= note: expected closure signature `for<'a> fn(&'a (), for<'a> fn(&'a ())) -> _`
137137
found closure signature `fn((), ()) -> _`
138138
note: required by a bound in `g2`
139-
--> $DIR/anonymous-higher-ranked-lifetime.rs:24:25
139+
--> $DIR/anonymous-higher-ranked-lifetime.rs:30:25
140140
|
141141
LL | fn g2<F>(_: F) where F: Fn(&(), fn(&())) {}
142142
| ^^^^^^^^^^^^^^^^ required by this bound in `g2`
@@ -146,7 +146,7 @@ LL | g2(|_: &(), _: ()| {});
146146
| +
147147

148148
error[E0631]: type mismatch in closure arguments
149-
--> $DIR/anonymous-higher-ranked-lifetime.rs:9:5
149+
--> $DIR/anonymous-higher-ranked-lifetime.rs:15:5
150150
|
151151
LL | g3(|_: (), _: ()| {});
152152
| ^^^--------------^^^^
@@ -157,7 +157,7 @@ LL | g3(|_: (), _: ()| {});
157157
= note: expected closure signature `for<'s> fn(&'s (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>) -> _`
158158
found closure signature `fn((), ()) -> _`
159159
note: required by a bound in `g3`
160-
--> $DIR/anonymous-higher-ranked-lifetime.rs:25:25
160+
--> $DIR/anonymous-higher-ranked-lifetime.rs:31:25
161161
|
162162
LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {}
163163
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g3`
@@ -167,7 +167,7 @@ LL | g3(|_: &(), _: ()| {});
167167
| +
168168

169169
error[E0631]: type mismatch in closure arguments
170-
--> $DIR/anonymous-higher-ranked-lifetime.rs:10:5
170+
--> $DIR/anonymous-higher-ranked-lifetime.rs:16:5
171171
|
172172
LL | g4(|_: (), _: ()| {});
173173
| ^^^--------------^^^^
@@ -178,7 +178,7 @@ LL | g4(|_: (), _: ()| {});
178178
= note: expected closure signature `for<'a> fn(&'a (), for<'r> fn(&'r ())) -> _`
179179
found closure signature `fn((), ()) -> _`
180180
note: required by a bound in `g4`
181-
--> $DIR/anonymous-higher-ranked-lifetime.rs:26:25
181+
--> $DIR/anonymous-higher-ranked-lifetime.rs:32:25
182182
|
183183
LL | fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
184184
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g4`
@@ -188,7 +188,7 @@ LL | g4(|_: &(), _: ()| {});
188188
| +
189189

190190
error[E0631]: type mismatch in closure arguments
191-
--> $DIR/anonymous-higher-ranked-lifetime.rs:11:5
191+
--> $DIR/anonymous-higher-ranked-lifetime.rs:17:5
192192
|
193193
LL | h1(|_: (), _: (), _: (), _: ()| {});
194194
| ^^^----------------------------^^^^
@@ -199,7 +199,7 @@ LL | h1(|_: (), _: (), _: (), _: ()| {});
199199
= note: expected closure signature `for<'a, 'b> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>, &'b (), for<'a, 'b> fn(&'a (), &'b ())) -> _`
200200
found closure signature `fn((), (), (), ()) -> _`
201201
note: required by a bound in `h1`
202-
--> $DIR/anonymous-higher-ranked-lifetime.rs:29:25
202+
--> $DIR/anonymous-higher-ranked-lifetime.rs:35:25
203203
|
204204
LL | fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {}
205205
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h1`
@@ -209,7 +209,7 @@ LL | h1(|_: &(), _: (), _: &(), _: ()| {});
209209
| + +
210210

211211
error[E0631]: type mismatch in closure arguments
212-
--> $DIR/anonymous-higher-ranked-lifetime.rs:12:5
212+
--> $DIR/anonymous-higher-ranked-lifetime.rs:18:5
213213
|
214214
LL | h2(|_: (), _: (), _: (), _: ()| {});
215215
| ^^^----------------------------^^^^
@@ -220,7 +220,7 @@ LL | h2(|_: (), _: (), _: (), _: ()| {});
220220
= note: expected closure signature `for<'a, 't0> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>, &'t0 (), for<'a, 'b> fn(&'a (), &'b ())) -> _`
221221
found closure signature `fn((), (), (), ()) -> _`
222222
note: required by a bound in `h2`
223-
--> $DIR/anonymous-higher-ranked-lifetime.rs:30:25
223+
--> $DIR/anonymous-higher-ranked-lifetime.rs:36:25
224224
|
225225
LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {}
226226
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h2`

tests/ui/parser/as-precedence.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Parser precedence test to help with [RFC 87 "Trait Bounds with Plus"][rfc-87], to check the
2+
//! precedence of the `as` operator in relation to some arithmetic bin-ops and parentheses.
3+
//!
4+
//! Editor's note: this test seems quite incomplete compared to what's possible nowadays. Maybe
5+
//! there's another set of tests whose coverage overshadows this test?
6+
//!
7+
//! [rfc-87]: https://rust-lang.github.io/rfcs/0087-trait-bounds-with-plus.html
8+
9+
//@ run-pass
10+
11+
#[allow(unused_parens)]
12+
fn main() {
13+
assert_eq!(3 as usize * 3, 9);
14+
assert_eq!(3 as (usize) * 3, 9);
15+
assert_eq!(3 as (usize) / 3, 1);
16+
assert_eq!(3 as usize + 3, 6);
17+
assert_eq!(3 as (usize) + 3, 6);
18+
}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//! Check that we don't get compile errors on unreachable code after the `{ return 3; }` artificial
2+
//! block below. This test is run-pass to also exercise the codegen, but it might be possible to
3+
//! reduce to build-pass or even check-pass.
4+
//!
5+
//! This test was introduced as part of commit `a833f152baa17460e8414355e832d30d5161f8e8` which
6+
//! removes an "artificial block". See also commit `3d738e9e0634a4cd6239d1317bd7dad53be68dc8` for
7+
//! more elaboration, reproduced below (this is outdated for *today*'s rustc as of 2024-12-10, but
8+
//! is helpful to understand the original intention):
9+
//!
10+
//! > Return a fresh, unreachable context after ret, break, and cont
11+
//! >
12+
//! > This ensures we don't get compile errors on unreachable code (see
13+
//! > test/run-pass/artificial-block.rs for an example of sane code that wasn't compiling). In the
14+
//! > future, we might want to warn about non-trivial code appearing in an unreachable context,
15+
//! > and/or avoid generating unreachable code altogether (though I'm sure LLVM will weed it out as
16+
//! > well).
17+
//!
18+
//! Since then, `ret` became `return`, `int` became `isize` and `assert` became a macro.
19+
20+
//@ run-pass
21+
22+
fn f() -> isize {
23+
{
24+
return 3;
25+
}
26+
}
27+
28+
fn main() {
29+
assert_eq!(f(), 3);
30+
}

0 commit comments

Comments
 (0)