forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
11 changed files
with
137 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
8 changes: 8 additions & 0 deletions
8
tests/ui/diagnostic-flags/allow-non-lint-warnings.without_flag.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
6 changes: 6 additions & 0 deletions
6
tests/ui/anonymous-higher-ranked-lifetime.rs → ...anked/anonymous-higher-ranked-lifetime.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |