Skip to content

Commit

Permalink
Unrolled build for rust-lang#133900
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer authored Dec 14, 2024
2 parents 327c7ee + 56efa0a commit 1d7329f
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 64 deletions.
19 changes: 0 additions & 19 deletions tests/ui/alias-uninit-value.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ui/allow-non-lint-warnings.rs

This file was deleted.

5 changes: 0 additions & 5 deletions tests/ui/artificial-block.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/as-precedence.rs

This file was deleted.

26 changes: 26 additions & 0 deletions tests/ui/codegen/alias-uninit-value.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! Regression test for issue #374, where previously rustc performed conditional jumps or moves that
//! incorrectly depended on uninitialized values.
//!
//! Issue: <https://github.com/rust-lang/rust/issues/374>.
//@ run-pass

#![allow(dead_code)]

enum TyS {
Nil,
}

struct RawT {
struct_: TyS,
cname: Option<String>,
hash: usize,
}

fn mk_raw_ty(st: TyS, cname: Option<String>) -> RawT {
return RawT { struct_: st, cname: cname, hash: 0 };
}

pub fn main() {
mk_raw_ty(TyS::Nil, None::<String>);
}
27 changes: 27 additions & 0 deletions tests/ui/diagnostic-flags/allow-non-lint-warnings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ignore-tidy-linelength
//! Check that `-A warnings` cli flag applies to non-lint warnings as well.
//!
//! This test tries to exercise that by checking that the "relaxing a default bound only does
//! something for `?Sized`; all other traits are not bound by default" non-lint warning (normally
//! warn-by-default) is suppressed if the `-A warnings` cli flag is passed.
//!
//! Take special note that `warnings` is a special pseudo lint group in relationship to non-lint
//! warnings, which is somewhat special. This test does not exercise other `-A <other_lint_group>`
//! that check that they are working in the same way, only `warnings` specifically.
//!
//! # Relevant context
//!
//! - Original impl PR: <https://github.com/rust-lang/rust/pull/21248>.
//! - RFC 507 "Release channels":
//! <https://github.com/rust-lang/rfcs/blob/c017755b9bfa0421570d92ba38082302e0f3ad4f/text/0507-release-channels.md>.
#![crate_type = "lib"]

//@ revisions: without_flag with_flag

//@[with_flag] compile-flags: -Awarnings

//@ check-pass

pub trait Trait {}
pub fn f<T: ?Trait>() {}
//[without_flag]~^ WARN relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
--> $DIR/allow-non-lint-warnings.rs:26:13
|
LL | pub fn f<T: ?Trait>() {}
| ^^^^^^

warning: 1 warning emitted

Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//! Diagnostics test to check that higher-ranked lifetimes are properly named when being pretty
//! printed in diagnostics.
//!
//! Issue: <https://github.com/rust-lang/rust/issues/44887>
//! PR: <https://github.com/rust-lang/rust/pull/44888>
fn main() {
f1(|_: (), _: ()| {}); //~ ERROR type mismatch
f2(|_: (), _: ()| {}); //~ ERROR type mismatch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0631]: type mismatch in closure arguments
--> $DIR/anonymous-higher-ranked-lifetime.rs:2:5
--> $DIR/anonymous-higher-ranked-lifetime.rs:8:5
|
LL | f1(|_: (), _: ()| {});
| ^^^--------------^^^^
Expand All @@ -10,7 +10,7 @@ LL | f1(|_: (), _: ()| {});
= note: expected closure signature `for<'a, 'b> fn(&'a (), &'b ()) -> _`
found closure signature `fn((), ()) -> _`
note: required by a bound in `f1`
--> $DIR/anonymous-higher-ranked-lifetime.rs:16:25
--> $DIR/anonymous-higher-ranked-lifetime.rs:22:25
|
LL | fn f1<F>(_: F) where F: Fn(&(), &()) {}
| ^^^^^^^^^^^^ required by this bound in `f1`
Expand All @@ -20,7 +20,7 @@ LL | f1(|_: &(), _: &()| {});
| + +

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

error[E0631]: type mismatch in closure arguments
--> $DIR/anonymous-higher-ranked-lifetime.rs:4:5
--> $DIR/anonymous-higher-ranked-lifetime.rs:10:5
|
LL | f3(|_: (), _: ()| {});
| ^^^--------------^^^^
Expand All @@ -52,7 +52,7 @@ LL | f3(|_: (), _: ()| {});
= note: expected closure signature `for<'a> fn(&(), &'a ()) -> _`
found closure signature `fn((), ()) -> _`
note: required by a bound in `f3`
--> $DIR/anonymous-higher-ranked-lifetime.rs:18:29
--> $DIR/anonymous-higher-ranked-lifetime.rs:24:29
|
LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {}
| ^^^^^^^^^^^^^^^ required by this bound in `f3`
Expand All @@ -62,7 +62,7 @@ LL | f3(|_: &(), _: &()| {});
| + +

error[E0631]: type mismatch in closure arguments
--> $DIR/anonymous-higher-ranked-lifetime.rs:5:5
--> $DIR/anonymous-higher-ranked-lifetime.rs:11:5
|
LL | f4(|_: (), _: ()| {});
| ^^^--------------^^^^
Expand All @@ -73,7 +73,7 @@ LL | f4(|_: (), _: ()| {});
= note: expected closure signature `for<'a, 'r> fn(&'a (), &'r ()) -> _`
found closure signature `fn((), ()) -> _`
note: required by a bound in `f4`
--> $DIR/anonymous-higher-ranked-lifetime.rs:19:25
--> $DIR/anonymous-higher-ranked-lifetime.rs:25:25
|
LL | fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f4`
Expand All @@ -83,7 +83,7 @@ LL | f4(|_: &(), _: &()| {});
| + +

error[E0631]: type mismatch in closure arguments
--> $DIR/anonymous-higher-ranked-lifetime.rs:6:5
--> $DIR/anonymous-higher-ranked-lifetime.rs:12:5
|
LL | f5(|_: (), _: ()| {});
| ^^^--------------^^^^
Expand All @@ -94,7 +94,7 @@ LL | f5(|_: (), _: ()| {});
= note: expected closure signature `for<'r> fn(&'r (), &'r ()) -> _`
found closure signature `fn((), ()) -> _`
note: required by a bound in `f5`
--> $DIR/anonymous-higher-ranked-lifetime.rs:20:25
--> $DIR/anonymous-higher-ranked-lifetime.rs:26:25
|
LL | fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f5`
Expand All @@ -104,7 +104,7 @@ LL | f5(|_: &(), _: &()| {});
| + +

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

error[E0631]: type mismatch in closure arguments
--> $DIR/anonymous-higher-ranked-lifetime.rs:8:5
--> $DIR/anonymous-higher-ranked-lifetime.rs:14:5
|
LL | g2(|_: (), _: ()| {});
| ^^^--------------^^^^
Expand All @@ -136,7 +136,7 @@ LL | g2(|_: (), _: ()| {});
= note: expected closure signature `for<'a> fn(&'a (), for<'a> fn(&'a ())) -> _`
found closure signature `fn((), ()) -> _`
note: required by a bound in `g2`
--> $DIR/anonymous-higher-ranked-lifetime.rs:24:25
--> $DIR/anonymous-higher-ranked-lifetime.rs:30:25
|
LL | fn g2<F>(_: F) where F: Fn(&(), fn(&())) {}
| ^^^^^^^^^^^^^^^^ required by this bound in `g2`
Expand All @@ -146,7 +146,7 @@ LL | g2(|_: &(), _: ()| {});
| +

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

error[E0631]: type mismatch in closure arguments
--> $DIR/anonymous-higher-ranked-lifetime.rs:10:5
--> $DIR/anonymous-higher-ranked-lifetime.rs:16:5
|
LL | g4(|_: (), _: ()| {});
| ^^^--------------^^^^
Expand All @@ -178,7 +178,7 @@ LL | g4(|_: (), _: ()| {});
= note: expected closure signature `for<'a> fn(&'a (), for<'r> fn(&'r ())) -> _`
found closure signature `fn((), ()) -> _`
note: required by a bound in `g4`
--> $DIR/anonymous-higher-ranked-lifetime.rs:26:25
--> $DIR/anonymous-higher-ranked-lifetime.rs:32:25
|
LL | fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g4`
Expand All @@ -188,7 +188,7 @@ LL | g4(|_: &(), _: ()| {});
| +

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

error[E0631]: type mismatch in closure arguments
--> $DIR/anonymous-higher-ranked-lifetime.rs:12:5
--> $DIR/anonymous-higher-ranked-lifetime.rs:18:5
|
LL | h2(|_: (), _: (), _: (), _: ()| {});
| ^^^----------------------------^^^^
Expand All @@ -220,7 +220,7 @@ LL | h2(|_: (), _: (), _: (), _: ()| {});
= note: expected closure signature `for<'a, 't0> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>, &'t0 (), for<'a, 'b> fn(&'a (), &'b ())) -> _`
found closure signature `fn((), (), (), ()) -> _`
note: required by a bound in `h2`
--> $DIR/anonymous-higher-ranked-lifetime.rs:30:25
--> $DIR/anonymous-higher-ranked-lifetime.rs:36:25
|
LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h2`
Expand Down
18 changes: 18 additions & 0 deletions tests/ui/parser/as-precedence.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! Parser precedence test to help with [RFC 87 "Trait Bounds with Plus"][rfc-87], to check the
//! precedence of the `as` operator in relation to some arithmetic bin-ops and parentheses.
//!
//! Editor's note: this test seems quite incomplete compared to what's possible nowadays. Maybe
//! there's another set of tests whose coverage overshadows this test?
//!
//! [rfc-87]: https://rust-lang.github.io/rfcs/0087-trait-bounds-with-plus.html
//@ run-pass

#[allow(unused_parens)]
fn main() {
assert_eq!(3 as usize * 3, 9);
assert_eq!(3 as (usize) * 3, 9);
assert_eq!(3 as (usize) / 3, 1);
assert_eq!(3 as usize + 3, 6);
assert_eq!(3 as (usize) + 3, 6);
}
30 changes: 30 additions & 0 deletions tests/ui/reachable/artificial-block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//! Check that we don't get compile errors on unreachable code after the `{ return 3; }` artificial
//! block below. This test is run-pass to also exercise the codegen, but it might be possible to
//! reduce to build-pass or even check-pass.
//!
//! This test was introduced as part of commit `a833f152baa17460e8414355e832d30d5161f8e8` which
//! removes an "artificial block". See also commit `3d738e9e0634a4cd6239d1317bd7dad53be68dc8` for
//! more elaboration, reproduced below (this is outdated for *today*'s rustc as of 2024-12-10, but
//! is helpful to understand the original intention):
//!
//! > Return a fresh, unreachable context after ret, break, and cont
//! >
//! > This ensures we don't get compile errors on unreachable code (see
//! > test/run-pass/artificial-block.rs for an example of sane code that wasn't compiling). In the
//! > future, we might want to warn about non-trivial code appearing in an unreachable context,
//! > and/or avoid generating unreachable code altogether (though I'm sure LLVM will weed it out as
//! > well).
//!
//! Since then, `ret` became `return`, `int` became `isize` and `assert` became a macro.
//@ run-pass

fn f() -> isize {
{
return 3;
}
}

fn main() {
assert_eq!(f(), 3);
}

0 comments on commit 1d7329f

Please sign in to comment.