-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add tests for some old fixed issues #131355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ad7d41c
Test for issue 23600
clubby789 b577b26
Add stdio configuring to run-make Rustc
clubby789 3afb7d6
Migrate `emit-to-stdout` to new run-make
clubby789 b27c22d
Add test for issue 28994
clubby789 fa4f18b
Add test for issue 30472
clubby789 382365b
Add test for issue 30867
clubby789 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,73 @@ | ||
//! If `-o -` or `--emit KIND=-` is provided, output should be written to stdout | ||
//! instead. Binary output (`obj`, `llvm-bc`, `link` and `metadata`) | ||
//! being written this way will result in an error if stdout is a tty. | ||
//! Multiple output types going to stdout will trigger an error too, | ||
//! as they would all be mixed together. | ||
//! | ||
//! See <https://github.com/rust-lang/rust/pull/111626>. | ||
|
||
use std::fs::File; | ||
|
||
use run_make_support::{diff, run_in_tmpdir, rustc}; | ||
|
||
// Test emitting text outputs to stdout works correctly | ||
fn run_diff(name: &str, file_args: &[&str]) { | ||
rustc().emit(format!("{name}={name}")).input("test.rs").args(file_args).run(); | ||
let out = rustc().emit(format!("{name}=-")).input("test.rs").run().stdout_utf8(); | ||
diff().expected_file(name).actual_text("stdout", &out).run(); | ||
} | ||
|
||
// Test that emitting binary formats to a terminal gives the correct error | ||
fn run_terminal_err_diff(name: &str) { | ||
#[cfg(not(windows))] | ||
let terminal = File::create("/dev/ptmx").unwrap(); | ||
// FIXME: If this test fails and the compiler does print to the console, | ||
// then this will produce a lot of output. | ||
// We should spawn a new console instead to print stdout. | ||
#[cfg(windows)] | ||
let terminal = File::options().read(true).write(true).open(r"\\.\CONOUT$").unwrap(); | ||
|
||
let err = File::create(name).unwrap(); | ||
rustc().emit(format!("{name}=-")).input("test.rs").stdout(terminal).stderr(err).run_fail(); | ||
diff().expected_file(format!("emit-{name}.stderr")).actual_file(name).run(); | ||
} | ||
|
||
fn main() { | ||
run_in_tmpdir(|| { | ||
run_diff("asm", &[]); | ||
run_diff("llvm-ir", &[]); | ||
run_diff("dep-info", &["-Zdep-info-omit-d-target=yes"]); | ||
run_diff("mir", &[]); | ||
|
||
run_terminal_err_diff("llvm-bc"); | ||
run_terminal_err_diff("obj"); | ||
run_terminal_err_diff("metadata"); | ||
run_terminal_err_diff("link"); | ||
|
||
// Test error for emitting multiple types to stdout | ||
rustc() | ||
.input("test.rs") | ||
.emit("asm=-") | ||
.emit("llvm-ir=-") | ||
.emit("dep-info=-") | ||
.emit("mir=-") | ||
.stderr(File::create("multiple-types").unwrap()) | ||
.run_fail(); | ||
diff().expected_file("emit-multiple-types.stderr").actual_file("multiple-types").run(); | ||
|
||
// Same as above, but using `-o` | ||
rustc() | ||
.input("test.rs") | ||
.output("-") | ||
.emit("asm,llvm-ir,dep-info,mir") | ||
.stderr(File::create("multiple-types-option-o").unwrap()) | ||
.run_fail(); | ||
diff() | ||
.expected_file("emit-multiple-types.stderr") | ||
.actual_file("multiple-types-option-o") | ||
.run(); | ||
|
||
// Test that `-o -` redirected to a file works correctly (#26719) | ||
rustc().input("test.rs").output("-").stdout(File::create("out-stdout").unwrap()).run(); | ||
}); | ||
} |
1 change: 1 addition & 0 deletions
1
.../ui/consts/issue-77062-large-zst-array.rs → tests/ui/consts/large-zst-array-77062.rs
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//@ build-pass | ||
pub static FOO: [(); usize::MAX] = [(); usize::MAX]; | ||
|
||
fn main() { | ||
let _ = &[(); usize::MAX]; | ||
|
This file contains hidden or 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,32 @@ | ||
//@ check-pass | ||
clubby789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//! Tests that associated type projections normalize properly in the presence of HRTBs. | ||
//! Original issue: <https://github.com/rust-lang/rust/issues/30472> | ||
|
||
|
||
pub trait MyFrom<T> {} | ||
impl<T> MyFrom<T> for T {} | ||
|
||
pub trait MyInto<T> {} | ||
impl<T, U> MyInto<U> for T where U: MyFrom<T> {} | ||
|
||
|
||
pub trait A<'self_> { | ||
type T; | ||
} | ||
pub trait B: for<'self_> A<'self_> { | ||
// Originally caused the `type U = usize` example below to fail with a type mismatch error | ||
type U: for<'self_> MyFrom<<Self as A<'self_>>::T>; | ||
} | ||
|
||
|
||
pub struct M; | ||
impl<'self_> A<'self_> for M { | ||
type T = usize; | ||
} | ||
|
||
impl B for M { | ||
type U = usize; | ||
} | ||
|
||
|
||
fn main() {} |
This file contains hidden or 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,22 @@ | ||
//@ check-pass | ||
clubby789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//! Tests that a HRTB + FnOnce bound involving an associated type don't prevent | ||
//! a function pointer from implementing `Fn` traits. | ||
//! Test for <https://github.com/rust-lang/rust/issues/28994> | ||
|
||
trait LifetimeToType<'a> { | ||
type Out; | ||
} | ||
|
||
impl<'a> LifetimeToType<'a> for () { | ||
type Out = &'a (); | ||
} | ||
|
||
fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out { | ||
val | ||
} | ||
|
||
fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { } | ||
|
||
fn main() { | ||
assert_fn(id); | ||
} |
This file contains hidden or 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,14 @@ | ||
//@ check-pass | ||
clubby789 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//! Tests that HRTB impl selection covers type parameters not directly related | ||
//! to the trait. | ||
//! Test for <https://github.com/rust-lang/rust/issues/30867> | ||
|
||
#![crate_type = "lib"] | ||
|
||
trait Unary<T> {} | ||
impl<T, U, F: Fn(T) -> U> Unary<T> for F {} | ||
fn unary<F: for<'a> Unary<&'a T>, T>() {} | ||
|
||
pub fn test<F: for<'a> Fn(&'a i32) -> &'a i32>() { | ||
unary::<F, i32>() | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.